populate data from Access Table into datagrid
Kindly help, i want to populate data from my access table into datagrid but i got this complain "run-time error '6147' column not found [1
Below is my code
Dim findstr As String
Dim cnn2 As ADODB.Connection
Dim rsSearch As ADODB.Recordset
If txtFind.Text = Empty Then
MsgBox "Enter the information to seach"
txtFind.SetFocus
Exit Sub
End If
findstr = "select * from CardCategory where Code = '" & txtFind.Text & "'"
Set cnn2 = New ADODB.Connection
cnn2.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & "Data Source = C:\BB\sh.mdb"
cnn2.Open
Set rsSearch = New ADODB.Recordset
rsSearch.Open findstr, cnn2, adOpenDynamic
If rsSearch.EOF And rsSearch.BOF Then
MsgBox "Invalid Entry", vbOKOnly, "Stop!!"
Exit Sub
End If
Do While Not rsSearch.EOF
DataGrid1.Columns(0).Value = rsSearch!Code
DataGrid1.Columns(1) = rsSearch!Description
Loop
|