0

I'm connecting from VB.NET 2013 to Access (System.Data.Odbc library, .accdb database format). The first query returns 16 rows and the second query returns 0. Is there some sort of caching problem going on here? Earlier in the code, I do clear out the table and insert the 16 records in.

This returns "16 0"

Dim dt1 As New DataTable, dt2 As New DataTable
Dim cnn As New Odbc.OdbcConnection("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=" & db & ";")
Dim da1 As New Odbc.OdbcDataAdapter("SELECT * FROM [sys_Current_Cells] WHERE [Inforce Table ID] > -9999", cnn)
Dim da2 As New Odbc.OdbcDataAdapter("SELECT * FROM [sys_Current_Cells] WHERE 1 = 1", cnn)
da1.Fill(dt1)
da2.Fill(dt2)
Debug.Print(dt1.Rows.Count & " " & dt2.Rows.Count)
Ben Kester
  • 23
  • 6
  • Have you tried it with vanilla code without that "helper"? – Ňɏssa Pøngjǣrdenlarp Jan 11 '16 at 23:04
  • That doesn't help. I cleaned up the post to remove the helper code. – Ben Kester Jan 11 '16 at 23:13
  • Restarting my computer didn't do anything. Compact and repair gets me standard functionality, until I clear and insert the rows. – Ben Kester Jan 11 '16 at 23:18
  • 3
    I tried this against a ms-access table (changed field names and table name), got the same row count. With that there is something else going on but not with the code presented. – Karen Payne Jan 11 '16 at 23:35
  • You might find [this answer](http://stackoverflow.com/a/17063542/2144390) to be of interest. In any case, a [mcve] of your issue would certainly help, especially given the comment from @KarenPayne above. – Gord Thompson Jan 12 '16 at 05:37
  • Thanks. I'm new here. Is there a way to upload a database, or should I populate the database from code? – Ben Kester Jan 12 '16 at 16:07
  • That's a little different behavior than what I was experiencing. The issue seems to be that the data is populated with a INSERT statement from an external database (IN keyword). Pulling the results to a datatable then inserting them manually seems to fix this issue and other issues. – Ben Kester Jan 12 '16 at 16:10

0 Answers0