用一个adodc控件连接SQL SERVER 
TEXT1绑定ID,TEXT2绑定PWD 都设置为不显示
TEXT3 TEXT4 
COMMADN1提交
if text3=text1,text4=text2 then
form2.show
else
.........
笨是笨了点,但可以实现

解决方案 »

  1.   

    我也用sql server 建立了一个user_info表 字段user_id和user_pwd有记录值user_id :1          user_pwd:1
    Option ExplicitPrivate Sub Command1_Click()
       On Error Resume Next   
       cmd.CommandText = "Select * from user_info where user_id= '" + Text1.Text + "' and user_pwd = '" + Text2.Text + "'"
       Set rs = cmd.Execute   
       If Err.Number Then
          MsgBox Err.Description, 16 + vbOKOnly, Err.Number
          Exit Sub
       End If   
       If rs.RecordCount <> 1 Then
          MsgBox "用户名不正确或密码不对,请重新输入!", 16 + vbOKOnly, "错误"
          Exit Sub
       End If
       End Sub
    模块Public db As New ADODB.Connection
    Public rs As New ADODB.Recordset
    Public cmd As New ADODB.CommandPublic i As Long
    Public MsgValue As VbMsgBoxResult
      

  2.   

    xks(轻风逐浪)  你的代码有 Bug。   cmd.CommandText = "Select * from user_info where user_id= '" + Text1.Text + "' and user_pwd = '" + Text2.Text + "'"应改成:   cmd.CommandText = "Select * from user_info where user_id= '" + Replace(Text1.Text,"'","''") + "' and user_pwd = '" + Replace(Text2.Text,"'","''") + "'"应该可以安全一点个。
      

  3.   

    噢,忘记主题了,不好意思。楼主,xks(轻风逐浪) 的方法是可行的。建议使用,当然还有别的方法,大致是原理是相同的。