[ADODC]:未指定RecordSource。 [ADO]:未为命令对象设置命令文本

时间:2012-08-03 09:19:09

标签: vb6 ado

下面是我正在使用的代码

Private Sub Form_Load()
    On Error Resume Next

    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Smart Invoice\Smartdata.mdb;Persist Security Info=False"
    Adodc1.RecordSource = "Select * From tableSerMast"

End Sub

我低于上述错误:

  

[ADODC]:未指定RecordSource。 [ADO]:未为命令对象

设置命令文本

1 个答案:

答案 0 :(得分:0)

我将假设VBA,如果这是你的意思,改为VB6应该不会太难。

 Private Sub Form_Load()
    ''Almost never a good idea
    ''On Error Resume Next
    ''Reference: Microsoft ActiveX Data Objects x.x Library
    Dim adodc1 As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
        & "Data Source=D:\Smart Invoice\Smartdata.mdb;" _
        & "Persist Security Info=False"
    Adodc1.Open

    rs.Open "Select * From tableSerMast", Adodc1
End Sub