求vb+sql server2000做个系统登录界面代码

来源:百度知道 编辑:UC知道 时间:2024/05/21 06:52:23
窗体已经画好,控件如下:1.text1:用户名,2.text2:密码,3.command1:确定,4.command2.取消,5.一个Adobe控件
数据库名称:db_MIS,数据表名称:tb_enter,用户名字段:M_Name,密码字段:M_Password,要求点“确定”按钮查询数据表(tb_enter)中用户名和密码和用户输入的是否一致,如果是则提示登录成功,否则失败。不要另外添加什么模块功能。程序代码最好每行都有注释,各位vb大侠指点小弟,高分相送!

工程,引用
Microsoft ActiveX Data Objects x版本

Dim Conn As New Connection
Dim Rs As New Recordset
Conn.ConnectionString= "Provider=SQLOLEDB.1;Password=密码;Persist Security Info=True;User ID=SQL登入名;Initial Catalog=库名;Data Source=SQL服务器IP
Conn.Open

Set Rs = Conn.Execute("Select * From tb_enter Where M_Name='" & Replace(text1.Text, "'", "''") & "' And M_Password='" & text2.Text & "'")
If Not Rs.EOF Then'如果符合
Rs.Close: Set Rs = Nothing
Conn.Close: Set Conn = Nothing
Unload Me'关闭现有窗体
Form1.Show'出现新窗体
Else'如果不符合
MsgBox "对不起,您的用户名密码不正确", vbCritical, "错误!"
Rs.Close: Set Rs = Nothing
Conn.Close: Set Conn = Nothing
End If

太简单了吧
我没有时间啊