VB与SQL SERVER做管理登陆口问题
初学VB,才疏学浅,希望大家帮我忙
用VB做一个登陆口
用户名+密码=登陆到form2.frm
我是用ADODC连接数据库 生成的字符串如下:
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=qqqq;Data Source=MICROSOF-698F11
登陆界面做好了,user.text和password.text
确定按钮Command1
数据表:password里面有user和password两个段
请问Command1_Click怎么写?
谢谢各位大哥
[解决办法]
Dim rst As New ADODB.Recordset
Dim Conn As New ADODB.Connection
Dim cnn As String
Dim strSQL As String
cnn = "Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=;Initial Catalog=;Data Source=127.0.0.1 "
strSQL = "select userid,pwd from userinfo order by userid "
With Conn
.CursorLocation = adUseClient
.ConnectionString = cnn
.ConnectionTimeout = 10
.Open
End With
strSQL = "select * from UserInfo where UserID= ' " & Trim(txtUser.Text) & " ' and pwd= ' " & Trim(txtPassWord.Text) & " ' "
Set rst = Conn.Execute(strSQL)
If rst.RecordCount > 0 Then
Load frmmain
frmmain.Show
Unload Me
Else
MsgBox "您的用戶名或密碼不對! ", vbInformation
txtUser.Text = " "
Exit Sub
End If