please help me, i need show data searching in datagrid. i have example code but its can't compile.
These coding examples that I made.


Option Explicit
Dim conn As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim query As String

Sub setConn()
Set conn = New ADODB.Connection
End Sub

Private Sub serachCmd_Click()
Set Rs = New Recordset
Adodc1.RecordSource = " select * from logfile where no_ponsel = '" & textSearch & "'"
Set LogDataGrid.DataSource = Adodc1
'Rs.Open " select * from logfile where no_ponsel = '" & textSearch & "'", conn, adOpenDynamic, adLockOptimistic

If Adodc1.Recordset.EOF Then
MsgBox "Record not found"
Else
LogDataGrid.DataSource = Adodc1 /* in this is error and message appear "method and data number not found"
LogDataGrid.Refresh
End If
End Sub

please help me..thanks

this is all the code that you have ?

yes is it, in my programs.
can you help me.

thanks for reply. :)

..can you help me ??? show the database using datagrid search..

You need to set the connection properties before using the setting the recordset connection properties

With conn
    .Provider = "Microsoft.Jet.OLEDB.3.51" ' or 4.01 or whatever
    .Open "c:\MyAccess.mdb", "admin", ""
End with

Set Rs = New Recordset
Adodc1.RecordSource = " select * from logfile where no_ponsel = '" & textSearch & "'"
Set LogDataGrid.DataSource = Adodc1
'Rs.Open " select * from logfile where no_ponsel = '" & textSearch & "'", conn, adOpenDynamic, adLockOptimistic

The recordset functions will not work until you properly set up the ADODB connection.

@ jeffrey blanz

declared any variable as string to have a value to read your database and datagrid. The code something like this:

any variable declare = "Select * FROM the filename of your recordsource" & if any command you use for selecting fields from your database & "='" & the declared variable & "'"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.