有必要用外部函數不?????
Dim strUserid, password As String
Dim objrs As New Recordset
Public objcn As New Connection
Private Sub Form_Load()
objcn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=登入名;Initial Catalog=數據庫名;Data Source=計算機名"
objrs.Open "t_login", objcn, adOpenKeyset, adLockOptimistic
End Sub
Private Sub connamd_Click()
Form5.Show
Unload Me
End Sub
Private Sub command_Click()
strUserid = Text1.Text
objrs.Requery
objrs.Find ("id = '" & strUserid & "'")
If objrs.EOF = False Then
If IIf(IsNull(objrs.Fields("password")), "", objrs.Fields("password")) = Text2.Text Then
strid = IIf(IsNull(objrs.Fields("id")), "", objrs.Fields("id"))
strname = IIf(IsNull(objrs.Fields("name")), "", objrs.Fields("name"))
Form1.Show
Unload Me
Else
MsgBox "密碼不正確"
Text2.Text = ""
Text2.SetFocus
Exit Sub
End If
Else
MsgBox "帳號不正確"
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
End Sub
Private Sub command_Click()
Unload Me
End Sub