各位大虾:
下面程序本来是VB+Access的,后来被我改成VB+SQL的。运行时在“Dat_Main.rsDat_class.State = 1”处报错,请问怎么改啊?
Private Sub Command1_Click()
Dim SQLoriginal As String
Dim SQLadd As String
Dim SQLorder As String
Dim strSql As String
SQLoriginal = "SELECT 年级,院系,专业,人数,辅导员,班长,备注 FROM 班级表 "
SQLadd = "WHERE 年级=年级 AND 专业=专业 "
SQLorder = "" If Check1.Value = 1 And IsNumeric(Text1) Then
SQLadd = SQLadd + "and 年级='" + Text1 + "'"
End If
If Check2.Value = 1 And Not IsNull(Text2) Then
SQLadd = SQLadd + "and 专业='" + Text2 + "'"
End If If Check3.Value = 1 And IsNumeric(Text3) Then
SQLadd = SQLadd + "and 人数='" + Text3 + "'"
End If If Check4.Value = 1 And Not IsNull(Text4) Then
SQLadd = SQLadd + "and 辅导员='" + Text4 + "'"
End If strSql = SQLoriginal + SQLadd + SQLorde If Dat_Main.rsDat_class.State = 1 Then
Dat_Main.rsDat_class.Close
End If Dat_Main.rsDat_class.Open strSql
Dat_Class.Show vbModal
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = "" End Sub Private Sub Command2_Click()
Unload Me
End Sub Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
下面程序本来是VB+Access的,后来被我改成VB+SQL的。运行时在“Dat_Main.rsDat_class.State = 1”处报错,请问怎么改啊?
Private Sub Command1_Click()
Dim SQLoriginal As String
Dim SQLadd As String
Dim SQLorder As String
Dim strSql As String
SQLoriginal = "SELECT 年级,院系,专业,人数,辅导员,班长,备注 FROM 班级表 "
SQLadd = "WHERE 年级=年级 AND 专业=专业 "
SQLorder = "" If Check1.Value = 1 And IsNumeric(Text1) Then
SQLadd = SQLadd + "and 年级='" + Text1 + "'"
End If
If Check2.Value = 1 And Not IsNull(Text2) Then
SQLadd = SQLadd + "and 专业='" + Text2 + "'"
End If If Check3.Value = 1 And IsNumeric(Text3) Then
SQLadd = SQLadd + "and 人数='" + Text3 + "'"
End If If Check4.Value = 1 And Not IsNull(Text4) Then
SQLadd = SQLadd + "and 辅导员='" + Text4 + "'"
End If strSql = SQLoriginal + SQLadd + SQLorde If Dat_Main.rsDat_class.State = 1 Then
Dat_Main.rsDat_class.Close
End If Dat_Main.rsDat_class.Open strSql
Dat_Class.Show vbModal
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = "" End Sub Private Sub Command2_Click()
Unload Me
End Sub Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
解决方案 »
- 类模块里添加match类型出错,用户定义类型未定义(高手Help)?
- 请问VB datareport打印问题
- 请教一些网络的问题,谢谢,也许表达不是太清楚,望见谅。
- VB如何启动本地文件,不需要指定的路径,打开一个文件夹的程序
- fpspead 的问题
- koa 3000 请进来~~~~~~~~~~~~
- 请问 Pie 函数的具体用法?
- 本人用VB可视化数据管理器打开Excel文件,表名为Sheet1$或'TS-X'$,运行SQL语句select * from Sheet1$出错,可能是表名含有$或',才出错,可不能改名,请问该如何写SQL语句?
- ********如何通过局域网实现文件的传输?请详解。*********
- 谁有瑞软表格控件的注册机,高分相送??????
- VBA获取word表格高度和宽度的问题
- 关于用command对象执行存贮过程的问题,cmd.CreateParameter中的参数名称必须与存贮过程中的参数名称相同吗?
Dat_Main.rsDat_class.Close
End If Dat_Main.rsDat_class.Open strSql
Dat_Class.Show vbModal
这两句调转过来有没有问题啊?