can anyone help me fix this code. i'm trying to select the tablename from a combo box and then display the table contents in a data grid. my backend is oracle.
Private Sub Command1_Click()
Dim table, str As String
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
table = DataCombo1.Text
str = "select * from " & table
cn.ConnectionString = "dsn=test;uid=test;pwd=test"
cn.Open
Adodc2.RecordSource = adCmdText
Adodc2.Recordset.Open str, cn, adOpenDynamic, adLockOptimistic ' object or with block variable not set
If rs.BOF And rs.EOF Then
MsgBox "no record"
Else
Adodc2.Refresh
Set DataGrid1.DataSource = Adodc2
DataGrid1.Refresh
End If
End Sub