VB怎么判断用户名和数据库里的有没有重复,如果重复就不会记录 15
IfText1.Text=""ThenLabel4.Caption="账号不能为空!"Label4.ForeColor=vbRedExitSubEndIfIfText2....
If Text1.Text = "" Then
Label4.Caption = "账号不能为空!"
Label4.ForeColor = vbRed
Exit Sub
End If
If Text2.Text = "" Then
Label4.Caption = "密码不能为空!"
Label4.ForeColor = vbRed
Exit Sub
End If
Call SJK(db) '调用数据库连接
StrSql = "Select * from A1 where MC='" & Text1.Text & "'" '数据表连接字符串
RS.Open StrSql, db, 2, 2 '打开数据表
If RS.EOF = True Then '用户名错误
Label4.Caption = "账号错误!请检查"
Label4.ForeColor = vbRed
RS.Close
db.Close
Exit Sub
Else
If Not RS!MM = Text2.Text Then '用户密码错误
Label4.Caption = "密码错误!请检查"
Label4.ForeColor = vbRed
Else
Form3.Show
Unload Form1
End If
End If
RS.Close
Set RS = Nothing
db.Close
Set db = Nothing
End Sub
这是申明:Public db As New ADODB.Connection '声明数据库连接对象
Public RS As New ADODB.Recordset '声明将来就对象
Public Sub SJK(db) '连接数据库过程
db.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);dbQ=" & App.Path & "\A.mdb"
db.Open
End Sub 展开
Label4.Caption = "账号不能为空!"
Label4.ForeColor = vbRed
Exit Sub
End If
If Text2.Text = "" Then
Label4.Caption = "密码不能为空!"
Label4.ForeColor = vbRed
Exit Sub
End If
Call SJK(db) '调用数据库连接
StrSql = "Select * from A1 where MC='" & Text1.Text & "'" '数据表连接字符串
RS.Open StrSql, db, 2, 2 '打开数据表
If RS.EOF = True Then '用户名错误
Label4.Caption = "账号错误!请检查"
Label4.ForeColor = vbRed
RS.Close
db.Close
Exit Sub
Else
If Not RS!MM = Text2.Text Then '用户密码错误
Label4.Caption = "密码错误!请检查"
Label4.ForeColor = vbRed
Else
Form3.Show
Unload Form1
End If
End If
RS.Close
Set RS = Nothing
db.Close
Set db = Nothing
End Sub
这是申明:Public db As New ADODB.Connection '声明数据库连接对象
Public RS As New ADODB.Recordset '声明将来就对象
Public Sub SJK(db) '连接数据库过程
db.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);dbQ=" & App.Path & "\A.mdb"
db.Open
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询