2 Replies - 447 Views - Last Post: 08 March 2015 - 04:59 AM Rate Topic: -----

#1 Noonaheart   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 24-February 15

data from ms access dont show in datagridview

Posted 08 March 2015 - 04:09 AM

data from ms access did not appear in datagrid view in vb.net.
I already check the query directly in ms access if it is working properly.
Here's the code.
the data type is text.


If ComboBoxLog.Text = "All" Then
Dim dt As New DataTable
Dim da As New OleDbDataAdapter("SELECT * FROM ProfessorLog where Petsa like '*03/*'", conn)
da.Fill(dt)
If dt.Rows.Count > 0 Then
DataGridProfLog.Rows.Clear()
For i As Integer = 0 To dt.Rows.Count - 1
DataGridProfLog.Rows.Add(dt.Rows(i).Item("Petsa"), dt.Rows(i).Item("TimeIn"), dt.Rows(i).Item("TimeOut"))
Next
End If
dt.Dispose()
dt = Nothing
da.Dispose()
da = Nothing



Is This A Good Question/Topic? 0
  • +

Replies To: data from ms access dont show in datagridview

#2 andrewsw   User is offline

  • blow up my boots
  • member icon

Reputation: 6546
  • View blog
  • Posts: 26,533
  • Joined: 12-December 12

Re: data from ms access dont show in datagridview

Posted 08 March 2015 - 04:40 AM

Does it work without the like clause?

If so, then I would try reversing '*03/*' to '*/03*', assuming that this is a Date/Time field. If it is then you should be using date functions, not treating the value as text. Treating a date-value as though it were text will always be problematic.
Was This Post Helpful? 0
  • +
  • -

#3 CharlieMay   User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1729
  • View blog
  • Posts: 5,708
  • Joined: 25-September 09

Re: data from ms access dont show in datagridview

Posted 08 March 2015 - 04:59 AM

Also, once you get the select working and since you're filling a datatable (dt) why not just select the 3 columns you want and set the datasource of the datagridview to your datatable?
also, you're inside an If statement, so it would be good to ensure that the If conditions is being met. (Remember, by default, string comparison is case-sensitive.

This post has been edited by CharlieMay: 08 March 2015 - 05:03 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1