Option Explicit
Dim n As Integer
Private Sub Form_Load()
n = 0
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command1_Click()
Dim txtSQL As String
Dim MsgText As String
Dim mrc As ADODB.Recordset
txtSQL = "select * from c001 where username='"
Trim$ (Text1(0).Text) & "'" & "and txtPassword='"
Trim$ (Text1(1).Text)
Set mrc = exeSQL(txtSQL)
If mrc.RecordCount = 0 Then '---为什么这里提示错误???
n = n + 1
If n < 3 Then
MsgBox "没有这个用户,继续登陆 ", vbOKOnly + vbExclamation, "信息提示"
Text1(0).Text = ""
Text1(1).Text = ""
Text1(0).SetFocus
Else
MsgBox "已经登陆三次,退出系统", vbOKOnly + vbExclamation, "信息提示"
Unload Me
End If
Else
userlevel = Trim(mrc.Fields("userleve"))
mrc.Close
Unload Me
frmMain.Show
End If
End Sub
Private Sub Text1_KeyPress(intex As Integer, KeyAscii As Integer)
Call endata(KeyAscii)
End Sub
模块代码是
Option Explicit
Public userlevel As String
Public adoCon As New ADODB.Connection
Public Cmd As New ADODB.Command
Public UserCode As String
Public UserName As String
Public OldSort As Integer
Sub main()
frmLogin.Show vbModal
End Sub
Public Function ConnectString() As String
ConnectString = "FileDSN=card.dsn;UID=sa;PWD="
End Function
Public Function exeSQL(ByVal SQL As String) As ADODB.Recordset
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
SQL = Trim$(SQL)
Set conn = New ADODB.Connection
Set rst = New ADODB.Recordset
conn.Open ConnectString
Set rst.ActiveConnection = conn
rst.LockType = adLockOptimistic
rst.CursorType = adOpenKeyset
rst.Open ConnectString
Set exeSQL = rst
Set rst = Nothing
Set conn = Nothing
End Function
Public Sub endata(Keyasc As Integer)
If Keyasc = 13 Then
SendKeys "{TAB}"
End If
End Sub
请高手帮忙修正下~~
万分感谢!!!!!
[此贴子已经被作者于2006-6-5 22:35:15编辑过]