2012-08-03 71 views
0

是我使用[ADODC]:沒有指定RecordSource。 [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]: no RecordSource specified. [ADO] :Command text was not set for the command object

回答

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