窗体上有3个text 的控件数组,输入后错误如下:[SQL SERVER]第一行=附近有错误
对象Refresh 的方法IAdodc 失败源代码如下:
Private Sub selcmd1_Click()condstr = "" '条件表达式初始值为空,以下根据用户的输入构造该条件表达式
If Trim(Text1(0).Text) <> "" Then
If condstr = "" Then
condstr = "姓名='" + Trim(Text1(0).Text) + "'"
Else
condstr = condstr + "and 姓名='" + Trim(Text1(0).Text) + "'"
End If
End If
'If Trim(Text1(1).Text) <> "" Then
'If condstr = "" Then
' condstr = "学号='" + Trim(Text1(1).Text) + "'"
'Else
' condstr = condstr + "and 学号='" + Trim(Text1(1).Text) + "'"
'End If
'End If
'If Trim(Text1(2).Text) <> "" Then
' If condstr = "" Then
' condstr = "课程='" + Trim(Text1(2).Text) + "'"
'Else
'' condstr = condstr + "and 课程='" + Trim(Text1(2).Text) + "'"
'End If
'End If
If condstr <> "" Then '有条件查找
Adodc1.RecordSource = "select *from bukao where" + condstr
Adodc1.Refresh
Else
Adodc1.RecordSource = "select *from bukao"
Adodc1.Refresh
End If
recs = Adodc1.Recordset.RecordCount
If recs = 0 Then
MsgBox "没有任何条件的记录", vbOKOnly, "信息提示"
End If
Call encomm
End Sub
对象Refresh 的方法IAdodc 失败源代码如下:
Private Sub selcmd1_Click()condstr = "" '条件表达式初始值为空,以下根据用户的输入构造该条件表达式
If Trim(Text1(0).Text) <> "" Then
If condstr = "" Then
condstr = "姓名='" + Trim(Text1(0).Text) + "'"
Else
condstr = condstr + "and 姓名='" + Trim(Text1(0).Text) + "'"
End If
End If
'If Trim(Text1(1).Text) <> "" Then
'If condstr = "" Then
' condstr = "学号='" + Trim(Text1(1).Text) + "'"
'Else
' condstr = condstr + "and 学号='" + Trim(Text1(1).Text) + "'"
'End If
'End If
'If Trim(Text1(2).Text) <> "" Then
' If condstr = "" Then
' condstr = "课程='" + Trim(Text1(2).Text) + "'"
'Else
'' condstr = condstr + "and 课程='" + Trim(Text1(2).Text) + "'"
'End If
'End If
If condstr <> "" Then '有条件查找
Adodc1.RecordSource = "select *from bukao where" + condstr
Adodc1.Refresh
Else
Adodc1.RecordSource = "select *from bukao"
Adodc1.Refresh
End If
recs = Adodc1.Recordset.RecordCount
If recs = 0 Then
MsgBox "没有任何条件的记录", vbOKOnly, "信息提示"
End If
Call encomm
End Sub
解决方案 »
- BHO中存取网页IPersist
- dim定义变量问题
- VB,Word 导出得问题,急!!!
- 我作的一个vb程序,生成EXE后执行,可是切换窗口后就找不到了?
- 如何读取*.csv的行数,不用循环做,在线等。。。
- winsock senddata 的问题:如何立即发出????
- VB高手请进
- 各位大哥,帮忙看一看,我的用户名验证代码有什么问题?
- 在activereport中加text控件,设好数据源后,将其cangrow设为true,当数据量超过text的大小时,text会自动加大,text下面的横线会自动向下
- 关于VBA中的计时器!
- 分辨率改变后,如何调整mdi窗口中子窗体显示?
- 两个问题,急求帮助
应该是少了空格
Adodc1.RecordSource = "select *from bukao where " + condstr
=======
where后面加个空格试试
像下面一样姓名前最好加个空格
condstr = "姓名='" + Trim(Text1(0).Text) + "'"