vb6.0本地登陆没有成功,测试失败
出现的错误提示str.Open strSQl, con, adOpenStatic, adLockReadOnly0、*.*文件和me.mdb都是同一目录
1、也引用了
microsoft activex data objects 2.0
microsoft data binding collection
2、也设成main启动
3、模块也定义了如下:
Public con As New Connection '定义数据连接,公共变量
Public coon, coom As String
Public str As Currency
Sub main()
ChDir App.Path '转换相对路径
con.ConnectionString = "rovider=Microsoft.Jet.OLEDB.4.0;Data Source=me.mdbersist Security Info=False"
'定义数据库连接
con.CursorLocation = adUseClient '以客户端的方式打开
con.Open ' 打开连接
Form1.Show
End Sub
4、在command1也设成了
Private Sub Command1_Click()
If id.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
id.SetFocus
Exit Sub
End If
If password.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
password.SetFocus
Exit Sub
End If
Dim strSQl As String
strSQl = "select * from Users where users_name='" & Trim$(id.Text) & "' and password='" & Trim$(password.Text) & "' "
Dim str As New ADODB.Recordset
Set str = New ADODB.Recordset
str.CursorLocation = adUseClient
str.Open strSQl, conn, adOpenStatic, adLockReadOnly
With str
If .State = adStateOpen Then .Close
.Open strSQl
If .EOF Then
Try_times = Try_times + 1
If Try_times >= 3 Then
MsgBox "您已经三次尝试进入本系统,均不成功,系统将自动关闭", vbOKOnly + vbCritical, "警告"
Unload Me
Else
MsgBox "对不起,用户名不存在或密码错误 !", vbOKOnly + vbQuestion, "警告"
id.SetFocus
id.Text = ""
password.Text = ""
End If
Else
Unload Me
Form2.Show '登录进入的另一个界面
End If
End With
End Sub