VB中连接无法用于执行此操作,在此上下文中他可能已被关闭或无效
我用的是VB做了一个登陆界面可以输入用户名和密码在登录按钮中加入了一下代码PrivateSubCommand1_Click()IfText1.Text=""ThenMsg...
我用的是VB 做了一个登陆界面 可以输入用户名和密码 在登录按钮中加入了一下代码
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "用户名不能为空,请输入用户名", vbOKOnly + vbInformation, "提示!"
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "密码不能为空,请输入密码", vbOKOnly + vbInformation, "提示!"
Exit Sub
End If
Dim strSQL As String
If Option3.Value = True Then
strSQL = "select * from 借书卡信息表 where 借书证号='" & Trim$(Text1.Text) & "' and 密码='" & Trim$(Text2.Text) & "' "
Dim str As New ADODB.Recordset
Set str = New ADODB.Recordset
str.CursorLocation = adUseClient
str.Open strSQL, conn, adOpenStatic, adLockReadOnly
If str.EOF = True Then
MsgBox "对不起,用户名不存在或密码错误 !", vbOKOnly + vbQuestion, "警告"
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
Else
Unload Me
Form2.Show
End If
End If
数据库中的借书证信息表中的 借书证号和密码分别是用户名和密码 出现了这个问题 怎么办
我已经在标准模块中加入了
Public conn As ADODB.Connection
Sub main()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _
+ "User ID=sa;password=;Initial Catalog=book;Data Source=94A56CA15936458\WINCC"
conn.Open
Form1.Show '登录界面
End Sub
是哪里出了问题 展开
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "用户名不能为空,请输入用户名", vbOKOnly + vbInformation, "提示!"
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "密码不能为空,请输入密码", vbOKOnly + vbInformation, "提示!"
Exit Sub
End If
Dim strSQL As String
If Option3.Value = True Then
strSQL = "select * from 借书卡信息表 where 借书证号='" & Trim$(Text1.Text) & "' and 密码='" & Trim$(Text2.Text) & "' "
Dim str As New ADODB.Recordset
Set str = New ADODB.Recordset
str.CursorLocation = adUseClient
str.Open strSQL, conn, adOpenStatic, adLockReadOnly
If str.EOF = True Then
MsgBox "对不起,用户名不存在或密码错误 !", vbOKOnly + vbQuestion, "警告"
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
Else
Unload Me
Form2.Show
End If
End If
数据库中的借书证信息表中的 借书证号和密码分别是用户名和密码 出现了这个问题 怎么办
我已经在标准模块中加入了
Public conn As ADODB.Connection
Sub main()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _
+ "User ID=sa;password=;Initial Catalog=book;Data Source=94A56CA15936458\WINCC"
conn.Open
Form1.Show '登录界面
End Sub
是哪里出了问题 展开
2个回答
展开全部
请在
Sub main()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _
+ "User ID=sa;password=;Initial Catalog=book;Data Source=94A56CA15936458\WINCC"
conn.Open
conn.open之后做断点查看conn.state是否为1
Sub main()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _
+ "User ID=sa;password=;Initial Catalog=book;Data Source=94A56CA15936458\WINCC"
conn.Open
conn.open之后做断点查看conn.state是否为1
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询