VB做的一个系统的登陆界面连数据库的一个表

VB登陆界面上的符合数据库中表(用户名和密码)就可登陆,否则报错点取消就可推出

第1个回答  2013-09-26
Dim rs As New ADODB.Recordset
Dim Conn As ADODB.Connection
Dim ConnectionString As String
Dim sql As String
If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "用户名,密码 不能为空"
Else
Set Conn = CreateObject("ADODB.Connection")
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\love.mdb;Persist Security Info=False;"
Conn.Open ConnectionString
sql = "select * from denglu where 用户名='" & Text1.Text & "' and 密码='" & Text2.Text & "'"

rs.Open sql, Conn, 3, 3
If Not rs.EOF Then
Form2.Show'跳到转向的页面
Else
MsgBox "用户名或密码错误,请重新输入"
End If
第2个回答  2013-09-26
str="select * from user where txtuser='" & txtuser.text & "' and txtpass='" & txtpassward & "'"
recordset.open str,conn,1,1
if recordset.RecordCount>0 then
load yourform
else
msgbox
endif
第3个回答  2013-09-26
用DATA控件,然后查询数据集就行了.
相似回答