Hi..
I try to connect a data grid (MS Data Grid Control 6.0 (oledb)) with ADO recordset.
Below is the source code :
-------------------------------
Private Sub Form_Load()
Dim objConn As ADODB.Connection
Dim objComm As ADODB.Command
Dim objRec As ADODB.Recordset
Dim strcon As String
Dim varBkmark
'Create and open the Connection object
Set objConn = New ADODB.Connection
strconn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Program Files\Microsoft Visual Studio\VB98\data.mdb; Persist Security Info=False"
objConn.ConnectionString = strconn
objConn.Open
'Create and set the Command object
Set objComm = New ADODB.Command
objComm.ActiveConnection = objConn
objComm.CommandText = "Stock"
objComm.CommandType = adCmdTable
'Create and set the Recordset object
Set objRec = New ADODB.Recordset
Set objRec.Source = objComm
objRec.CursorType = adOpenKeyset
objRec.Open
Set DataGrid1.DataSource = objRec
DataGrid1.Refresh
End Sub
-----------------
Ques : why i did'nt see anything on the datagrid? what's wrong with the code?
note :
1. i didn't receive any error message
2. the database & table is fine, because i can get the expected result if i use ADODC(data control) component instead of using ADO coding.
thanks in advance...
Try objrec.refresh after the objrec.open
Hope this helps
Ivanc