質問

I ran this morning in a problem I can't find answer anywhere, so now I'm just asking to people who might have more knowledge than me on the subject ;). So here's the problem, when I'm executing a certain query in MS Access I got the rows I am expecting to receive, no problem there. However, when I run the exact same command (copy-paste) in an OleDbCommand object, it doesn't return anything. My datatable is empty. I'll copy the query so you might spot a difference in the syntax I might not be aware of:

odbCommand = New OleDbCommand( _
    "SELECT IDTemps, NomEmploye, HreAllouees, HreReelles, TauxHoraire, " & _
    " Description, NoProjet_Short, NoJob, Type FROM TableA " & _
    " WHERE NoProjet_Short = '13015' " & _
    " AND Type = 'DessinE' ", odbConnection)

    dbAdapter = New OleDbDataAdapter(odbCommand)
    odbConnection.Open()
    dbAdapter.Fill(dtTable)

Note: this is the core of the code, did not paste the error management (since I have no error, my DataTable is just empty, and should not be).

Thanks Simon

役に立ちましたか?

解決

Ok well after a complete day of testing a LOT of different data, table configuration, many many change in my query, I finally found the answer to my problem. Steve helped me lot in this one in testing with actual database by showing me te path to the Holy Grail : the damn connection string ;).

My connection string was actually good, but I have many of them and the database I was pointing to in my VB.NET application was not the one I was modifying using MS Access.

Final word on this: always double-check the ConnectionString (and thx Steve) :)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top