vb用户登录实例中数据库里有很多用户名和相对应的密码如何编写代码可以一一对应登录
2个回答
展开全部
Public conn As New ADODB.Connection
Public rs1 As New ADODB.Recordset
Private Sub Command1_Click()
cnstr = "Provider=SQLOLEDB;Data Source=数据库服务器名;DATABASE=数据库;UID=数据库用户名;pwd=密码"
conn.Open cnstr
If "& Text1.Text&" <> " " Then
sql = " select * from wuser where username='" & Text1.Text & "'"
rs1.Open sql, conn, 3, 3
MsgBox ("hello")
If (rs1.Fields("password") = Text2.Text) Then
Form2.Show
rs1.Close
Set rs1 = Nothing
Else
MsgBox ("用户名或者密码错误!")
End If
Else
MsgBox ("无效用户")
End If
conn.Close
End Sub
Public rs1 As New ADODB.Recordset
Private Sub Command1_Click()
cnstr = "Provider=SQLOLEDB;Data Source=数据库服务器名;DATABASE=数据库;UID=数据库用户名;pwd=密码"
conn.Open cnstr
If "& Text1.Text&" <> " " Then
sql = " select * from wuser where username='" & Text1.Text & "'"
rs1.Open sql, conn, 3, 3
MsgBox ("hello")
If (rs1.Fields("password") = Text2.Text) Then
Form2.Show
rs1.Close
Set rs1 = Nothing
Else
MsgBox ("用户名或者密码错误!")
End If
Else
MsgBox ("无效用户")
End If
conn.Close
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询