hi it 's working but the Grid view not disp.lay the details
Dim cn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;" & "Data Source=D:\Task_one_one\TaskNew\TaskNew\App_Data\db1.mdb")
cn.Open()
Try
Dim myTable As DataTable = New DataTable("MyTable")
'Dim ds As DataSet = New DataSet
myTable.Columns.Add(New DataColumn("Emp Id"))
myTable.Columns.Add(New DataColumn("Start Time"))
myTable.Columns.Add(New DataColumn("End Time"))
myTable.Columns.Add(New DataColumn("Hours"))
myTable.Columns.Add(New DataColumn("Date"))
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Log WHERE (Emp_id=" & TextBox1.Text & ")", cn)
Dim dr As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.Default)
Dim myRow As DataRow
While dr.Read()
myRow = myTable.NewRow
myRow.Item(0) = dr(0)
myRow.Item(1) = dr(1)
myRow.Item(2) = dr(2)
myRow.Item(3) = dr(3) '
myRow.Item(4) = dr(4)
myTable.Rows.Add(myRow)
End While
dr.Close()
'Add datatable to datagridview
Dim myData4 As DataTable = myTable
Dim ds = New DataSet()
ds.Tables.Add(myData4)
GridView1.DataSource = myData4
'GridView1.DataSource = myTable
GridView1.DataBind()
Catch ex As Exception
'MsgBox(ex.ToString) 'Show error when something goes wrong
Label1.Text = ex.ToString
End Try
cn.Close()