am using vb6
but i can't hwo to vie the data base content in data grid
Here is my code

Dim cn1 As ADODB.Connection
Dim rs1 As ADODB.Recordset
Dim ser As String
ser = ("select * from student where ID='" & Text5.Text & "'")
Set cn1 = New ADODB.Connection
cn1.Provider = "Microsoft.Jet.OLEDB.4.0"
cn1.Open "F:\Personal\Sumith\Study\My project\Vb project\adodc conection through code\student.mdb"
Set rs1 = New ADODB.Recordset
rs1.Open ser, cn1, adOpenStatic
If rs1.EOF And rs1.BOF Then
MsgBox "No record found"
End If
Set DataGrid1.DataSource = rs1
DataGrid1.Refresh

but i can't hwo to vie the data base content in data grid

Is that typing mistake? Anyway about Datagrid and MS Access DB you can read previous solved thread on such topic. It was discussed many times.
thanks

Just pull an ADODC control from the Components on to the Form where you have the Datagrid. Right click on ADODC, select ADODCProperties and click, one menu will open for you, Click on Build, highlight Microsoft Jet 4.0 for OLE..., click Next, Find your Database by clicking on the small unnamed button, then press the Test Connection. If the msg. says Test Connection Succeeded, you may prodeed to write the SQL statement by selecting the Record Source. There inside the Command Text (SQL) write the codes inside as follows:
Select *
From Tablename
Order by fieldname

Apply and save it.

Then click on the Datagrid. Under Properties, select DataSource select the ADODC that you assigned. Run the prj. Automatically the Database fields will appear on the Datagrid.

Change the following to -

If rs1.EOF And rs1.BOF Then
MsgBox "No record found"
End If
Set DataGrid1.DataSource = rs1
DataGrid1.Refresh

If rs1.EOF And rs1.BOF Then
MsgBox "No record found"
Else
Set DataGrid1.DataSource = rs1

Add the else and remove the refresh part. Only refresh your grid once you added a new record or you have changed any data criteria.

This article has been dead for over six months. Start a new discussion instead.