急求VB登陆窗体源码

来源:百度知道 编辑:UC知道 时间:2024/04/30 15:20:21
textbox1.text输入用户名
textbox2.text输入密码

然后Button钮来检测..

如果数据库表中存在数据,就提示登陆成功,,反之则提示失败..

拜托..急用
能否给出全部的代码,小弟菜鸟一个...连接SQL数据库..

'先封装用户类cUser
'cUser类中提供Verify()方法

sub Button_click()
dim User as new cUser
if not User.Verify(用户名,密码) then
'成功
主窗体.show 1
else
msgbox "出错的相关描述",0,"error"
end if
end sub

if textbox1.text=userid adn textbox2.text=userpass then
'能过了嘛
els
'错了没有能过
end if

Set Conn = New Adodb.Connection
Conn.ConnectionString = "provider=SQLOLEDB;SERVER=服务器IP;uid=用户名;pwd=密码;database=数据库名"
Conn.Open()
Dim sql,username,password as string
username = textbox1.text
password = textbox2.text
sql = "select password from 用户表 where 用户名字段='" & username & "'"
Set Rs = New Adodb.RecordSet
Rs.Open(SQL,Conn,1,1)
If Rs.EOF Then
没有这个用户
ElseIf Rs.Fields(0).Value = password Then
正确的用户名和密码
Else
密码错误
End If
'//---------------