vb连接access数据库: Public Const strCNaccess As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=c:\program files\common files\car.mdb;" & "Jet OLEDB:Database Password="
Dim pwdCount As IntegerPrivate Sub cmdcancel_click() Unload Me Exit Sub End SubPrivate Sub Form_Load() pwdCount = 0 End Sub Private Sub CmdOK_Click() Dim sql As String Dim rs As ADODB.Recordset If Trim(UserName.Text = "") Then MsgBox "没有输入用户名称,请重新输入!", vbOKOnly + vbExclamation, "警告" UserName.SetFocus Else sql = "select *from UserInfo where UserID='" & UserName.Text & "'" Set rs = TransactSQL(sql) If iflag = 1 Then If rs.EOF = True Then MsgBox "没有这个用户,请重新输入!", vbOKOnly + vbExclamation, "警告" UserName.SetFocus Else If Trim(rs.Fields(1)) = Trim(PassWord.Text) Then rs.Close Me.Hide gUserName = Trim(UserName.Text) '保存用户名称 FrmMain.Show Unload Me Else MsgBox "密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告" PassWord.SetFocus PassWord.Text = "" End If End If Else Unload Me End If End If End Sub
Public Const strCNaccess As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=c:\program files\common files\car.mdb;" & "Jet OLEDB:Database Password="
Unload Me
Exit Sub
End SubPrivate Sub Form_Load()
pwdCount = 0
End Sub
Private Sub CmdOK_Click()
Dim sql As String
Dim rs As ADODB.Recordset
If Trim(UserName.Text = "") Then
MsgBox "没有输入用户名称,请重新输入!", vbOKOnly + vbExclamation, "警告"
UserName.SetFocus
Else
sql = "select *from UserInfo where UserID='" & UserName.Text & "'"
Set rs = TransactSQL(sql)
If iflag = 1 Then
If rs.EOF = True Then
MsgBox "没有这个用户,请重新输入!", vbOKOnly + vbExclamation, "警告"
UserName.SetFocus
Else
If Trim(rs.Fields(1)) = Trim(PassWord.Text) Then
rs.Close
Me.Hide
gUserName = Trim(UserName.Text) '保存用户名称
FrmMain.Show
Unload Me
Else
MsgBox "密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
PassWord.SetFocus
PassWord.Text = ""
End If
End If
Else
Unload Me
End If
End If
End Sub