Groups | Blog | Home
all groups > dotnet windows forms databinding > october 2005 >

dotnet windows forms databinding : Results of query are not returned in DataAdapter Fill method


bordsby
10/20/2005 11:26:19 PM
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
10/21/2005 12:00:00 AM
Hi,

[quoted text, click to view]

When using JET though ADO(.NET) you must use different wildcarts, % instead
of * and _ instead of ?.

HTH,
Greetings


[quoted text, click to view]

bordsby
10/21/2005 8:43:04 AM
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
AddThis Social Bookmark Button