Windows Form Application, MSAccess Database, VB.NET
I am having a very strange problem with the OleDb.OleDbDataAdapter.Fill
method.... I have used this method thousands of times with success and
have never had any problems, but recently I have a query that will
definitely return multiple rows when run from inside MSAccess, but when
passed through the OleDb.OleDbDataAdapter.Fill method, the result comes
back with no rows, but I know *for sure* that the query does indeed
come back with some rows. I have output the query one line before the
fill method is called and then run it from inside MSAccess and rows are
returned, but then nothing comes back in the fill method. This method
has worked perfectly with many, many other queries...... so, what's
different about this query? This is the first time I have passed use
the 'Like' operator in the 'WHERE' clause of the query... if I take the
'Like' operator out, everything is fine, but when I put it in, the
query still selects rows when run inside MSAccess, but the fill method
gets nothing.
Has anybody ever experienced this particular symptom? I have always
been successful in binding a datagrid to an MSAccess table, but as soon
as I put the 'Like' operator in the query, everything is ignored... I
pasted the few relevant lines of code here, but not the query, since
that is not critical, becuase I am sure it returns rows and is
syntactically correct.
____________________________________________________________________________
Public connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
source=data.db"
Public conn As OleDb.OleDbConnection = New
OleDb.OleDbConnection(connStr)
Public q As OleDb.OleDbCommand = New OleDb.OleDbCommand("", conn)
Public da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter
Public ds As DataSet = New DataSet
Public b2b_dt As DataTable = ds.Tables.Add("b2b")
b2b_dt.Clear()
q.CommandText = [long select query]
da.SelectCommand = q
da.Fill(Me.b2b_dt)
_____________________________________________________________________________
Bart Mermuys - 21 Oct 2005 16:10 GMT
Hi,
> Windows Form Application, MSAccess Database, VB.NET
>
[quoted text clipped - 14 lines]
> query still selects rows when run inside MSAccess, but the fill method
> gets nothing.
When using JET though ADO(.NET) you must use different wildcarts, % instead
of * and _ instead of ?.
HTH,
Greetings
> Has anybody ever experienced this particular symptom? I have always
> been successful in binding a datagrid to an MSAccess table, but as soon
[quoted text clipped - 17 lines]
> da.Fill(Me.b2b_dt)
> _____________________________________________________________________________
bordsby - 21 Oct 2005 16:43 GMT
Bart,
Thank you very much, that was indeed the problem... so I use * for the
wildcard when running the query inside MSAccess, and % for the
wildcard when going through ADO.NET
That really helps me out, I appreciate it