I created a small program to test running a "Like" query but I can't seem to get any results. I don't get any errors, it just doesn't populate the dataset. Here's the code:
I did "step through" the program and again, I don't get any errors but I also don't get any results.
I need to get this down because I will need this concept in my next program.
What am I doing wrong? If I run this exact code but the following sql, it populates fine.
VB.NET:
Private Sub btnLoadLike_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLoadLike.Click
'initialize the connection object
myConnection = New OleDb.OleDbConnection(connString)
'initialize the sql statement
mySql = "SELECT tblAssocInfo.Acid, tblAssocInfo.FirstName,
tblAssocInfo.LastName " & _
"FROM(tblAssocInfo) " & _
"WHERE (((tblAssocInfo.Acid) Like 'rpf*'));"
'initialize the data adapter object
myDataAdapter = New OleDb.OleDbDataAdapter(mySql, myConnection)
'initialize the data set object
myDataSet = New DataSet()
'fill the data set using the data adapter object
myDataAdapter.Fill(myDataSet)
'get the maximum number of records in the dataset
maxRec = (myDataSet.Tables(0).Rows.Count - 1)
'check for empty
If maxRec > -1 Then
'call the displayrecord sub below
DisplayRecord()
'enable the record buttons
Me.btnFirst.Enabled = True
Me.btnLast.Enabled = True
Me.btnPrevious.Enabled = True
Me.btnNext.Enabled = True
Else
MessageBox.Show("No Records Were Loaded")
End If
End Sub
I did "step through" the program and again, I don't get any errors but I also don't get any results.
I need to get this down because I will need this concept in my next program.
What am I doing wrong? If I run this exact code but the following sql, it populates fine.
VB.NET:
mySql = "SELECT tblAssocInfo.Acid, tblAssocInfo.FirstName, tblAssocInfo.LastName " & _
"FROM(tblAssocInfo) " & _
"WHERE (((tblAssocInfo.Acid)='cin0018'));"
Last edited: