用VB写的登陆窗口代码有错误,请帮忙修改一下,谢谢!
PrivateSubcmdwj_Click()DimzipAsStringDimTextusernameAsStringDimpassAsStringDimstrsqlA...
Private Sub cmdwj_Click()
Dim zip As String
Dim Textusername As String
Dim pass As String
Dim strsql As String
Textusername = Me.cmduser.Text
zip = Trim(InputBox("请输入此账号对应的认证码", "找回密码"))
If zip = "" Or Textusername = "" Then
MsgBox "账户或邮编号码不能为空", , "错误提示"
Else
Dim rc As ADODB.Recordset
Set rc = New ADODB.Recordset
strsql = " select * from Dbuser where Dbusername='" & Textusername & " ' and zipcode ='" & zip & "' "
rc.Open strsql, cnn, adOpenStatic, adLockReadOnly
If rc.EOF Then
MsgBox "您的输入有误", vbCritical, "提示"
i = i - 1
Label1.Caption = "您还有 " & i & " 次机会"
If i = 0 Then End
Else
pass = rc.Fields("Dbpassword").Value
MsgBox "你的密码是 " & pass & " 请妥善保管!", vbInformation, "密码提示"
Set rc = Nothing
rc.Close
pass = ""
End If
End If
End Sub
Private Sub Command1_Click()
Form2.Show 1
End Sub
Private Sub Form1_Load()
Option Explicit
Dim cnn As ADODB.Connection
Dim i As Integer
Public Privilege As String '连接Access数据库
Set cnn = New ADODB.Connection
cnn.Provider = "Microsoft.Jet.OLEDB.4.0;Data Source=E:\学习\金额管理系统 V0.1\Data\MangeDB.mdb;Persist Security Info=False"
Dim cnnFile As String
cnnFile = "Data Source=" & App.Path & "E:\学习\金额管理系统 V0.1\Data\MangeDB.mdb;Persist Security Info=False;Jet OLEDB:Database"
cnn.Open cnnFile '检测数据库是否链接成功
If cnn.State = adStateOpen Then
MsgBox "成功", 64, "数据库连接"
Else
MsgBox "失败,请检查数据库文件", 48, "数据库连接"
End If
i = 3
Label1.Caption = "您还有 " & i & " 次机会"
End Sub
Private Sub ok_Click()
Dim Textusername As String
Dim Textpassword As String
Dim rs As ADODB.Recordset
Dim strsql As String
Dim temp As String
cmduser = cmduser.Text
cmdpassword = cmdpassword.Text
If Me.cmduser.Text = "" Or Me.cmdpassword.Text = "" Then
i = i - 1
If i = 0 Then End '限制登陆次数
MsgBox "用户名和密码不能为空", 48, "提示"
Me.cmduser.SetFocus '账号或密码为空提示检查
Else
Set rs = New ADODB.Recordset
strsql = "select * from Dbuser where Dbusername='" & Textusername & " ' and Dbpassword='" & Textpassword & "'"
rs.Open strsql, cnn, adOpenStatic, adLockReadOnly 'Open table "DBser"
If rs.EOF Then
MsgBox "用户名或密码错误", vbCritical, "提示"
i = i - 1
Label1.Caption = "您还有 " & i & " 次机会"
Me.cmduser = ""
Me.cmdpassword = ""
Me.cmduser.SetFocus
Else
Privilege = rs.Fields("Privilege").Value '从数据库取得privilege值 判断权限 提示用户
If Privilege = "admin" Then
temp = "管理员账号"
Else: temp = "普通用户账号"
End If
MsgBox "你是" & temp & " ", 64, "权限提示"
rs.Close
Set rs = Nothing
cnn.Close
Unload Me
Form3.Show 1
End If '从数据库检查用户名和密码的正确性
End If
End Sub
我点确定后,程序说运行错误:rs.Open strsql, cnn, adOpenStatic, adLockReadOnly 'Open table "DBser"里面这段话有问题,我不知道如何解决,请高手..注册界面的注册我不能够自由存储用户信息,呜呜......我昨天整了一天都没有得到解决,请教高手....不胜感激.(希望拿出解决方案行吗?OK后我再补分给您) 或加我 QQ339528329,帮个忙吧,我在线等... 展开
Dim zip As String
Dim Textusername As String
Dim pass As String
Dim strsql As String
Textusername = Me.cmduser.Text
zip = Trim(InputBox("请输入此账号对应的认证码", "找回密码"))
If zip = "" Or Textusername = "" Then
MsgBox "账户或邮编号码不能为空", , "错误提示"
Else
Dim rc As ADODB.Recordset
Set rc = New ADODB.Recordset
strsql = " select * from Dbuser where Dbusername='" & Textusername & " ' and zipcode ='" & zip & "' "
rc.Open strsql, cnn, adOpenStatic, adLockReadOnly
If rc.EOF Then
MsgBox "您的输入有误", vbCritical, "提示"
i = i - 1
Label1.Caption = "您还有 " & i & " 次机会"
If i = 0 Then End
Else
pass = rc.Fields("Dbpassword").Value
MsgBox "你的密码是 " & pass & " 请妥善保管!", vbInformation, "密码提示"
Set rc = Nothing
rc.Close
pass = ""
End If
End If
End Sub
Private Sub Command1_Click()
Form2.Show 1
End Sub
Private Sub Form1_Load()
Option Explicit
Dim cnn As ADODB.Connection
Dim i As Integer
Public Privilege As String '连接Access数据库
Set cnn = New ADODB.Connection
cnn.Provider = "Microsoft.Jet.OLEDB.4.0;Data Source=E:\学习\金额管理系统 V0.1\Data\MangeDB.mdb;Persist Security Info=False"
Dim cnnFile As String
cnnFile = "Data Source=" & App.Path & "E:\学习\金额管理系统 V0.1\Data\MangeDB.mdb;Persist Security Info=False;Jet OLEDB:Database"
cnn.Open cnnFile '检测数据库是否链接成功
If cnn.State = adStateOpen Then
MsgBox "成功", 64, "数据库连接"
Else
MsgBox "失败,请检查数据库文件", 48, "数据库连接"
End If
i = 3
Label1.Caption = "您还有 " & i & " 次机会"
End Sub
Private Sub ok_Click()
Dim Textusername As String
Dim Textpassword As String
Dim rs As ADODB.Recordset
Dim strsql As String
Dim temp As String
cmduser = cmduser.Text
cmdpassword = cmdpassword.Text
If Me.cmduser.Text = "" Or Me.cmdpassword.Text = "" Then
i = i - 1
If i = 0 Then End '限制登陆次数
MsgBox "用户名和密码不能为空", 48, "提示"
Me.cmduser.SetFocus '账号或密码为空提示检查
Else
Set rs = New ADODB.Recordset
strsql = "select * from Dbuser where Dbusername='" & Textusername & " ' and Dbpassword='" & Textpassword & "'"
rs.Open strsql, cnn, adOpenStatic, adLockReadOnly 'Open table "DBser"
If rs.EOF Then
MsgBox "用户名或密码错误", vbCritical, "提示"
i = i - 1
Label1.Caption = "您还有 " & i & " 次机会"
Me.cmduser = ""
Me.cmdpassword = ""
Me.cmduser.SetFocus
Else
Privilege = rs.Fields("Privilege").Value '从数据库取得privilege值 判断权限 提示用户
If Privilege = "admin" Then
temp = "管理员账号"
Else: temp = "普通用户账号"
End If
MsgBox "你是" & temp & " ", 64, "权限提示"
rs.Close
Set rs = Nothing
cnn.Close
Unload Me
Form3.Show 1
End If '从数据库检查用户名和密码的正确性
End If
End Sub
我点确定后,程序说运行错误:rs.Open strsql, cnn, adOpenStatic, adLockReadOnly 'Open table "DBser"里面这段话有问题,我不知道如何解决,请高手..注册界面的注册我不能够自由存储用户信息,呜呜......我昨天整了一天都没有得到解决,请教高手....不胜感激.(希望拿出解决方案行吗?OK后我再补分给您) 或加我 QQ339528329,帮个忙吧,我在线等... 展开
3个回答
展开全部
cnnFile = "Data Source=" & App.Path & "E:\学习\金额管理系统 V0.1\Data\MangeDB.mdb;Persist Security Info=False;Jet OLEDB:Database"
这句呵,太搞笑了。App.Path是工程文件所在目录,假如你的工程保存在C盘,那数据库的地点就是"C:\E:\学习\金额管理系统 V0.1\Data\MangeDB.mdb"了,联系上下文,应该把这句改成这样:
cnnFile = "Data Source=E:\学习\金额管理系统 V0.1\Data\MangeDB.mdb;Persist Security Info=False;Jet OLEDB:Database"
这句呵,太搞笑了。App.Path是工程文件所在目录,假如你的工程保存在C盘,那数据库的地点就是"C:\E:\学习\金额管理系统 V0.1\Data\MangeDB.mdb"了,联系上下文,应该把这句改成这样:
cnnFile = "Data Source=E:\学习\金额管理系统 V0.1\Data\MangeDB.mdb;Persist Security Info=False;Jet OLEDB:Database"
展开全部
cnnFile = "Data Source=" & App.Path & "E:\学习\金额管理系统 V0.1\Data\MangeDB.mdb;Persist Security Info=False;Jet OLEDB:Database"
这个是不是有问题哦。路径有问题
给个参考
dim conn As new ADODB.Connection
Dim mstr As String
mstr = App.Path
If Right(mstr, 1) <> "\" Then
mstr = mstr + "\"
End If
mstr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & mstr & "\Data\MangeDB.mdb"
If conn.State <> 1 Then
conn.Open mstr
End If
Dim strsql As String
strsql = "select * from Dbuser where Dbusername='" & Textusername & " ' and Dbpassword='" & Textpassword & "'"
Dim rs As New ADODB.Recordset
rs.Open sql, cnn, 1, 1
这个是不是有问题哦。路径有问题
给个参考
dim conn As new ADODB.Connection
Dim mstr As String
mstr = App.Path
If Right(mstr, 1) <> "\" Then
mstr = mstr + "\"
End If
mstr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & mstr & "\Data\MangeDB.mdb"
If conn.State <> 1 Then
conn.Open mstr
End If
Dim strsql As String
strsql = "select * from Dbuser where Dbusername='" & Textusername & " ' and Dbpassword='" & Textpassword & "'"
Dim rs As New ADODB.Recordset
rs.Open sql, cnn, 1, 1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没怎么细看,但这句有点问题:
cnnFile = "Data Source=" & App.Path & "E:\学习\金额管理系统 V0.1\Data\MangeDB.mdb;Persist Security Info=False;Jet OLEDB:Database"
你的数据库到你是在"E:\学习\金额管理系统 V0.1\Data“下,还是APP.Path下的某个目录,岂有程序目录下再有根目录的
cnnFile = "Data Source=" & App.Path & "E:\学习\金额管理系统 V0.1\Data\MangeDB.mdb;Persist Security Info=False;Jet OLEDB:Database"
你的数据库到你是在"E:\学习\金额管理系统 V0.1\Data“下,还是APP.Path下的某个目录,岂有程序目录下再有根目录的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询