用vb连接sql数据库时总是提示:ADODC:没有指定记录源[ADO]:没有为命令对象设置命令
Private Sub cmdQuery_Click()Dim strSQL As String
Dim strCon(2) As String
Dim intCount As Integer
Dim i As Integer
intCount = 0
If Text1.Text <> "" Then
If Check1.Value = 1 Then
strCon(1) = "名称 like'%" & Text1.Text & " % '"
Else
strCon(1) = "名称='" & Text1.Text & "'"
End If
Else
strCon(1) = ""
End If
If Text2.Text <> "" Then
If Check1.Value = 1 Then
strCon(2) = "产品种类 like'%" & Text2.Text & " % '"
Else
strCon(2) = "产品种类='" & Text2.Text & "'"
End If
Else
strCon(2) = ""
End If
If strCon(1) = "" And strCon(2) = "" Then
strSQL = "select*from sxsyb where"
For i = 1 To 2
If strCon(i) <> "" Then
intCount = intCount + 1
If intCount = 1 Then
strSQL = strSQL + strCon(i)
Else
strSQL = strSQL + "and" + strCon(i)
End If
End If
Next
End If
Adodc1.ConnectionString = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\sxsyb.mdb;Persist Security Info=False"
= adCmdText
Adodc1.RecordSource = strSQL
Adodc1.Refresh
End Sub
运行程序就会在Adodc1.Refresh处显示没有为命令对象设置命令,本人新手希望哪位兄台看看哪错了,感激不尽!!!!