Hi!
I am trying to combine 2 datatables into 1. Why? Here it is.
I have this Table structure in my database for (attendance monitoring).
AttendanceID EmpID Time Date Event
1 758 08:03AM 2013-12-08 TI
2 758 05:45PM 2013-12-08 TO
3 1112 08:12AM 2013-12-08 TI
4 1112 05:50PM 2013-12-08 TO
where TI = timein and TO = timeout.
Then, I will be displaying it to a listview in vb.net like
EmpID Date TimeIn TimeOut
758 2013-12-08 08:03AM 05:45PM
1112 2013-12-08 08:12AM 05:50PM
what Im doing is that I called it in SQL like:
...
I tried combining datatable the same way as above code but it did not work. That's why I tried filling dataset but still got no result.
is there any way to do this?
Thanks in advance
I am trying to combine 2 datatables into 1. Why? Here it is.
I have this Table structure in my database for (attendance monitoring).
AttendanceID EmpID Time Date Event
1 758 08:03AM 2013-12-08 TI
2 758 05:45PM 2013-12-08 TO
3 1112 08:12AM 2013-12-08 TI
4 1112 05:50PM 2013-12-08 TO
where TI = timein and TO = timeout.
Then, I will be displaying it to a listview in vb.net like
EmpID Date TimeIn TimeOut
758 2013-12-08 08:03AM 05:45PM
1112 2013-12-08 08:12AM 05:50PM
what Im doing is that I called it in SQL like:
Code:
Dim getIn As String = "Select * from tblattendance on Event = 'TI' ORDER BY Date asc"
da = New MySqlDataAdapter(getIn, con)
Dim getOut As String = "Select * from tblattendance on Event = 'TO' ORDER BY Date asc"
da = New MySqlDataAdapter(getIn, con)
ds = New DataSet
da.Fill(ds, "tblattendance1")
da.Fill(ds, "tblattendance2")
ds.Tables("tblattendance1").Columns.Add("TimeIn")
ds.Tables("tblattendance1").Columns.Add("DateC")
ds.Tables("tblattendance2").Columns.Add("TimeOut")
For Each row As DataRow In ds.Tables("tblattendance1").Rows
row("TimeIn") = String.Format("{0:hh:mm tt}", row("Time"))
row("DateC") = String.Format("{0:MMM dd,yyyy}", row("Date"))
Next
For Each row1 As DataRow In ds.Tables("tblattendance2").Rows
row1("TimeOut") = String.Format("{0:hh:mm tt}", row1("Time"))
Next
For i As Integer = 0 To dt.Rows.Count - 1
Dim lv As ListViewItem = lvEmployees.Items.Add(ds.Tables("tblattendance1").Rows(i).Item("EmpID").ToString)
With lv
.SubItems.Add(ds.Tables("tblattendance1").Rows(i).Item("LName").ToString)
.SubItems.Add(ds.Tables("tblattendance1").Rows(i).Item("FName").ToString)
.SubItems.Add(ds.Tables("tblattendance1").Rows(i).Item("MName").ToString)
.SubItems.Add(ds.Tables("tblattendance1").Rows(i).Item("DateC"))
.SubItems.Add(ds.Tables("tblattendance1").Rows(i).Item("TimeIn"))
'.SubItems.Add(ds.Tables("tblattendance2").Rows(i).Item("TimeOut").ToString)
End With
Next
I tried combining datatable the same way as above code but it did not work. That's why I tried filling dataset but still got no result.
is there any way to do this?
Thanks in advance