VB登陆界面问题

来源:百度知道 编辑:UC知道 时间:2024/05/22 19:41:30
如何使登陆界面上的用户名. 密码 .与SQL连接,求详细代码!!

Dim constr As String
constr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=lzx"
cnn.Open constr

Private Sub Command1_Click()
Dim sql As String
Dim rst As New ADODB.Recordset
If n = 3 Then
Unload Me
Else
sql = "select * from mima where username='" + Me.Combo1.Text + "'and password='" + Text2.Text + "'"
rst.Open sql, cnn, adOpenKeyset, adLockReadOnly
If rst.RecordCount > 0 Then '数据库中查没查到这个用户(查询到的次数)
qwe = rst.Fields(2)
Frmain.Show
username = Me.Combo1.Text
Unload Me
Else
MsgBox "您的用户名或密码有误,请核对后重新输入", 0, "警告"
Combo1.SetFocus
n = n + 1
End If
End If

End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim sql As String