标题:用vb连接sql数据库时总是提示:ADODC:没有指定记录源[ADO]:没有为命令对象设 ...
只看楼主
本来很陈旧
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2013-4-21
结帖率:75%
 问题点数:0 回复次数:0 
用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处显示没有为命令对象设置命令,本人新手希望哪位兄台看看哪错了,感激不尽!!!!
搜索更多相关主题的帖子: sql数据库 
2013-04-28 17:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-405844-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.475432 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved