Results 1 to 2 of 2

Thread: data grid doesnt fetch data

Hybrid View

  1. #1
    Junior Member
    Join Date
    Jan 02
    Posts
    22

    Question data grid doesnt fetch data

    hi,

    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

  2. #2
    Addicted Member PsudoLogical's Avatar
    Join Date
    Dec 00
    Location
    Upstate N.Y.
    Posts
    144
    Private Sub Command1_Click()
    Dim table, con, str As String
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset

    table = DataCombo1.Text
    str = "select * from " & table
    con = "dsn=test;uid=test;pwd=test"

    Adodc2.ConnectionString = con
    Adodc2.RecordSource = str


    'If rs.BOF And rs.EOF Then
    'MsgBox "no record"
    'Else
    Adodc2.Refresh
    Set DataGrid1.DataSource = Adodc2
    DataGrid1.Refresh
    'End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •