RS变量定义,解决即给分,急!!!!!

zjh216 2003-05-19 11:44:37
Option Explicit

Private Sub Combo1_Click()
Text1.Text = ""
Text1.SetFocus
Select Case Combo1.Text

Case "按身份证号"
Label3.Caption = "如:42015689851565"


Case "按姓名"
Label3.Caption = ""
Case "按出生日期"
Label3.Caption = "如:1999-9-8"
Case "按籍贯"
Label3.Caption = ""
Case "按性别"
Label3.Caption = ""
End Select
End Sub

Private Sub Command1_Click()

Set rs = New ADODB.Recordset

Select Case Combo1.Text
Case "按姓名"
CString = "huzhuming='"
Case "按性别"
CString = "xingbie='"
Case "按身份证号"
CString = "shengfenhao='"
Case "按出生日期"
CString = "shengri='"
Case "籍贯"
CString = "jiguan='"

End Select
CString = CString & Trim(Text1.Text) & "'"
rs.Open "select * from HUJI-3 where " & Trim(CString), conn, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then
MSHFlexGrid1.Visible = True
Set MSHFlexGrid1.DataSource = rs
Text1.Text = ""
Text1.SetFocus
Else
MSHFlexGrid1.Visible = False
MsgBox "没有此记录"
Text1.Text = ""
Text1.SetFocus
End If
End Sub

Private Sub Command2_Click()
Unload Me
Load hecaozuo3
hecaozuo3.Show
End Sub

Private Sub Form_Load()
Label5.Left = (Me.ScaleWidth - Label5.Width) / 2
Label5.Top = 200

End Sub

系统提示 Private Sub Command1_Click()

Set rs = New ADODB.Recordset
rs变量未定义,请求帮助修改!如果还有其他问题请一并帮忙指出,谢谢!!!
...全文
46 点赞 收藏 14
写回复
14 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
caoshangfei 2003-05-20
呵呵。。在vb里面如果用到Option Explicit。那么所有的变量都需要定义,凡是出现什么变量没有定义的情况,你都在Option Explicit这句话的下面加上 dim 你所用到的变量。
回复
zjh216 2003-05-20
conn变量没有定义。
回复
caoshangfei 2003-05-20
呵呵。出错提示是什么???
回复
zjh216 2003-05-20
是不是的,是vb程序。vb区现在没有高手,只有来此地请教!能帮我修改以下吗?
回复
caoshangfei 2003-05-20
呵呵。你的不是asp程序吧。。
回复
zjh216 2003-05-20
草上非,谢谢赐教!可是还是不能正确运行能帮我修改一下吗?
回复
caoshangfei 2003-05-20
Option Explicit
dim rs
回复
zjh216 2003-05-20
小弟知识少。在哪儿加,请详加说明?谢谢!!!!
回复
caoshangfei 2003-05-20
在上面加上dim rs
回复
jshao 2003-05-20
应该是这样
set rs=server.createobject("ADODB.Recordset")
可参考
形式1
set rs = Server.CreateObject("ADODB.RecordSet")
strConn = "driver={SQL Server};server=srv;"& _
"uid=sa;pwd=;database=pubs"
strSQL = "Select * From Employee ;"
rs.open strSQL,strConn,,,adCmdText
形式2
set conn = Server.CreateObject("ADODB.Connection")
strConn ="driver={SQL Server};server=srv;"& _
"uid=sa;pwd=;database=pubs"
conn.open strConn
set rs = Server.CreateObject("ADODB.RecordSet")
rs.ActiveConnection=conn(注意此句)
strSQL = "Select * From Employee ;"
rs.open strSQL,,,,adCmdText
"上面这句也可以写成rs.open strSQL,conn,,,adCmdText
形式3
set conn = Server.CrreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.RecordSet")
strConn ="driver={SQL Server};server=srv;"& _
"uid=sa;pwd=;database=pubs"
conn.open strConn
strSQL = "Select * From Employee ;"
rs=conn.Execu strSQL(注意次句)
形式4
set rs = Server.CreateObject("ADODB.RecordSet")
strConn ="driver={SQL Server};server=srv;"& _
"uid=sa;pwd=;database=pubs"
strSQL = "Select * From Employee ;"
rs.open strSQL,strConn,,,adCmdText
回复
for example
dim i as integer
dim c as string
dim b as double
and so on
回复
caoshangfei 2003-05-20
呵呵。dim就是定义变量了。。只是起个告诉程序你要用到这个变量而已。我也只是稍微接触过vb..不能完全回答你的问题,抱歉。。
回复
zjh216 2003-05-20
小弟,初次接触vb,至于dim定义的具体语言不是特别了解,请详加指教,谢谢!!!
回复
qjrein 2003-05-19
应该是这样
set rs=server.createobject("ADODB.Recordset")
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2003-05-19 11:44
社区公告
暂无公告