实例功能数据库AccessVBVisual(账号密码变量为空错误)「access数据库用户名和密码」

登录1Private Sub Command登录_Click()If Text密码 = "" ThenMsgBox "登录密码不能为空"Exit SubEnd IfIf Text密码 = "abc123" Then MsgBox "登录成功" Unload Form登录1 Form系统主页1.Show 1Else MsgBox "登录密码不正确"End IfEnd Sub登录2Public login_count As LongPrivate Sub Command登录_Click()Dim 账号text As String '定义变量存储账号Dim 密码text As String '定义变量存储密码If Trim(Text账号) <> "" Then '输入账号不能为空账号text = Me.Text账号 '存储录入账号到变量中(可拓展更多判断,如字符长度等)ElseMsgBox "账号不能为空
"Exit SubEnd IfIf Trim(Me.Text密码) <> "" Then '输入密码不能为空 If Len(Trim(Me.Text密码)) < 6 Then MsgBox "密码长度不能小于6位
" Exit Sub End If密码text = Me.Text密码 '存储录入密码到变量中(可拓展更多判断,如字符长度等)ElseMsgBox "密码不能为空
"Exit SubEnd If'-账号密码验证Dim login_conn As New ADODB.Connection '连接到ACCESS数据库With login_conn 'mdb格式连接 .ConnectionString = "Provider = microsoft.jet.oledb.4.0;data source=" & App.Path & "\db_data.mdb;Jet OLEDB:DataBase password=abc123;persist security info=false" .OpenEnd WithDim login_rs As New ADODB.RecordsetDim login_sql As Stringlogin_sql = "select from 用户表 where 账号= '" & Me.Text账号 & "' and 密码='" & Me.Text密码 & "'" '查询用户表login_rs.Open login_sql, login_conn, adOpenDynamic, adLockOptimisticIf login_rs.EOF = False Then '循环表的内容On Error Resume Nextuser_name = login_rs.Fields("账号").Value '账号赋值到公共变量MsgBox "登录成功"Unload Me '关闭登录窗体Form系统主页2.Show 1ElseMsgBox "账号或密码错误,请重新登录"login_count = login_count + 1 '登录错误3次,退出 If login_count = 3 Then MsgBox "账号或密码错误达3次" Unload Me End IfEnd Iflogin_rs.CloseSet login_rs = Nothinglogin_conn.CloseSet login_conn = NothingExit Sub登录3Public login_count As LongPrivate Sub Command登录_Click()Dim 账号text As String '定义变量存储账号Dim 密码text As String '定义变量存储密码If Trim(Text账号) <> "" Then '输入账号不能为空账号text = Me.Text账号 '存储录入账号到变量中(可拓展更多判断,如字符长度等)ElseMsgBox "账号不能为空
"Exit SubEnd IfIf Trim(Me.Text密码) <> "" Then '输入密码不能为空 If Len(Trim(Me.Text密码)) < 6 Then MsgBox "密码长度不能小于6位
" Exit Sub End If密码text = Me.Text密码 '存储录入密码到变量中(可拓展更多判断,如字符长度等)ElseMsgBox "密码不能为空
"Exit SubEnd If'-账号密码验证Dim login_conn As New ADODB.Connection '连接到ACCESS数据库With login_conn 'mdb格式连接 .ConnectionString = "Provider = microsoft.jet.oledb.4.0;data source=" & App.Path & "\db_data.mdb;Jet OLEDB:DataBase password=abc123;persist security info=false" .OpenEnd WithDim login_rs As New ADODB.RecordsetDim login_sql As Stringlogin_sql = "select from 用户表 where 账号= '" & Me.Text账号 & "'" '查询用户表login_rs.Open login_sql, login_conn, adOpenDynamic, adLockOptimisticIf login_rs.EOF = False Then '循环表的内容On Error Resume Next If 密码text = login_rs.Fields("密码").Value Then user_name = login_rs.Fields("账号").Value '账号赋值到公共变量 MsgBox "登录成功" Unload Me '关闭登录窗体 Form系统主页3.Show 1 Else MsgBox "密码错误" login_count = login_count + 1 '登录错误3次,退出 If login_count = 3 Then MsgBox "密码错误达3次" Unload Me End If End IfElseMsgBox "账号不存在"End Iflogin_rs.CloseSet login_rs = Nothinglogin_conn.CloseSet login_conn = NothingExit Sub登录失败错误:MsgBox Err.DescriptionEnd Sub登录4Private Sub Command登录_Click()Dim 账号text As String '定义变量存储账号Dim 密码text As String '定义变量存储密码If Trim(Text账号) <> "" Then '输入账号不能为空账号text = Me.Text账号 '存储录入账号到变量中(可拓展更多判断,如字符长度等)ElseMsgBox "账号不能为空
"Exit SubEnd IfIf Trim(Me.Text密码) <> "" Then '输入密码不能为空 If Len(Trim(Me.Text密码)) < 6 Then MsgBox "密码长度不能小于6位
" Exit Sub End If密码text = Me.Text密码 '存储录入密码到变量中(可拓展更多判断,如字符长度等)ElseMsgBox "密码不能为空
"Exit SubEnd If'-账号密码验证Adodc1.RecordSource = "Select from 用户表 Where 账号='" & 账号text & "'" '筛选ADO控件记录Adodc1.RefreshIf Adodc1.Recordset.RecordCount = 1 Then ' If 密码text = Adodc1.Recordset.Fields("密码").Value Then user_name = 账号text '账号赋值到公共变量 MsgBox "登录成功" Unload Me '关闭登录窗体 Form系统主页3.Show 1 Else MsgBox "密码错误" login_count = login_count + 1 '登录错误3次,退出 If login_count = 3 Then MsgBox "密码错误达3次" Unload Me End If End IfElseMsgBox "账号不存在"End IfExit Sub登录失败错误:MsgBox Err.DescriptionEnd Sub登录5Public login_count As LongPrivate Sub Command登录_Click()Dim 账号text As String '定义变量存储账号Dim 密码text As String '定义变量存储密码If Trim(Text账号) <> "" Then '输入账号不能为空账号text = Me.Text账号 '存储录入账号到变量中(可拓展更多判断,如字符长度等)ElseMsgBox "账号不能为空
"Exit SubEnd IfIf Trim(Me.Text密码) <> "" Then '输入密码不能为空 If Len(Trim(Me.Text密码)) < 6 Then MsgBox "密码长度不能小于6位
" Exit Sub End If密码text = Me.Text密码 '存储录入密码到变量中(可拓展更多判断,如字符长度等)ElseMsgBox "密码不能为空
"Exit SubEnd If'-账号密码验证Dim login_conn As New ADODB.Connection '连接到ACCESS数据库With login_conn '连接 .ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;pwd=123123;Initial Catalog=test1;Data Source=(local)" .OpenEnd WithDim login_rs As New ADODB.RecordsetDim login_sql As Stringlogin_sql = "select from 用户表 where 账号= '" & Me.Text账号 & "' and 密码='" & Me.Text密码 & "'" '查询用户表login_rs.Open login_sql, login_conn, adOpenDynamic, adLockOptimisticIf login_rs.EOF = False Then '循环表的内容'On Error Resume Nextuser_name = login_rs.Fields("账号").Value '账号赋值到公共变量MsgBox "登录成功"Unload Me '关闭登录窗体Form系统主页3.Show 1ElseMsgBox "账号或密码错误,请重新登录"login_count = login_count + 1 '登录错误3次,退出 If login_count = 3 Then MsgBox "账号或密码错误达3次" Unload Me End IfEnd Iflogin_rs.CloseSet login_rs = Nothinglogin_conn.CloseSet login_conn = NothingExit Sub登录6Public login_count As LongPrivate Sub Command登录_Click()Dim 账号text As String '定义变量存储账号Dim 密码text As String '定义变量存储密码If Trim(Text账号) <> "" Then '输入账号不能为空账号text = Me.Text账号 '存储录入账号到变量中(可拓展更多判断,如字符长度等)ElseMsgBox "账号不能为空
"Exit SubEnd IfIf Trim(Me.Text密码) <> "" Then '输入密码不能为空 If Len(Trim(Me.Text密码)) < 6 Then MsgBox "密码长度不能小于6位
" Exit Sub End If密码text = Me.Text密码 '存储录入密码到变量中ElseMsgBox "密码不能为空
"Exit SubEnd If'-账号密码验证Adodc1.RecordSource = "Select from 用户表 Where 账号='" & 账号text & "'" '筛选ADO控件记录Adodc1.RefreshIf Adodc1.Recordset.RecordCount = 1 Then '' MsgBox 密码text & Adodc1.Recordset.Fields("密码").Value Dim A1 As String A1 = CStr(Adodc1.Recordset.Fields("密码").Value) If 密码text = Trim(A1) Then user_name = 账号text '账号赋值到公共变量 MsgBox "登录成功" Unload Me '关闭登录窗体 Form系统主页3.Show 1 Else MsgBox "密码错误" login_count = login_count + 1 '登录错误3次,退出 If login_count = 3 Then MsgBox "密码错误达3次" Unload Me End If End IfElseMsgBox "账号不存在"End IfExit Sub登录失败错误:MsgBox Err.DescriptionEnd Sub系统主页Private Sub Form_Load()Text账号.Text = user_nameEnd Sub公共变量Public user_name As String '记录登录账号
实例功能数据库AccessVBVisual(账号密码变量为空错误)
(图片来源网络,侵删)

联系我们

在线咨询:点击这里给我发消息