Option Explicit
Public g_ws As Workspace
Public g_db As Database
Public g_rs As Recordset
Public g_strsql As String
Public readerid As String
Public readeridR As String
Public Sub dbl()
Set g_ws = DBEngine.Workspaces(0)
Set g_db = g_ws.OpenDatabase(App.Path + "\db2.mdb", False, False, ";pwd=xgg2213")
End Sub
上面是我的模块代码
Option Explicit
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "请填写用户名!", vbInformation + vbOKOnly, "警告"
Text1.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "请填写密码!", vbInformation + vbOKOnly, "警告"
Text2.SetFocus
Exit Sub
End If
g_strsql = "select * from systeminfo where 名称='" & Text1.Text & "' and 密码='" & Text2.Text & "'"
Set g_rs = g_db.OpenRecordset(g_strsql)
If Not g_rs.EOF Then
Text1.Text = g_rs!名称
Text2.Text = g_rs!密码
If g_rs!超级管理员 = True Then
MsgBox "用户:" + Text1.Text + "你当前的身份是超级管理员,登陆时间:" + MDIForm1.StatusBar1.Panels(4).Text + "", vbInformation + vbOKOnly, "登陆信息"
MDIForm1.mfwork.Enabled = True
MDIForm1.mfadd.Enabled = True
MDIForm1.mfedit.Enabled = True
MDIForm1.mfsysteminfo.Enabled = True
MDIForm1.MDTJ = True
MDIForm1.StatusBar1.Panels(3).Text = "当前操作员:" & Text1.Text & " 登陆身份:超级管理员"
End If
If g_rs!数据库维护员 = True Then
MsgBox "用户:" + Text1.Text + "你当前的身份是数据库维护员,登陆时间:" + MDIForm1.StatusBar1.Panels(4).Text + "", vbInformation + vbOKOnly, "登陆信息"
MDIForm1.mfadd.Enabled = True
MDIForm1.mfedit.Enabled = True
MDIForm1.mfsysteminfo.Enabled = True
MDIForm1.mfsetadmin.Enabled = False
MDIForm1.MDTJ = True
MDIForm1.StatusBar1.Panels(3).Text = "当前操作员:" & Text1.Text & " 登陆身份:数据库维护员"
End If
If g_rs!图书管理员 = True Then
MsgBox "用户:" + Text1.Text + "你当前的身份是图书管理员,登陆时间:" + MDIForm1.StatusBar1.Panels(4).Text + "", vbInformation + vbOKOnly, "登陆信息"
MDIForm1.mfwork.Enabled = True
MDIForm1.mfedit = True
MDIForm1.StatusBar1.Panels(3).Text = "当前操作员:" & Text1.Text & "登陆身份:图书管理员"
End If
Text1.Text = ""
Text2.Text = ""
Me.Hide
Else
MsgBox "对不起,你输入的用户和密码不正确,请重新输入!", vbInformation + vbOKOnly, "警告"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
Set g_rs = Nothing
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
dbl
End Sub
Private Sub text1_keypress(keyascii As Integer)
If keyascii = "13" Then
Text2.SetFocus
End If
End Sub
Private Sub text2_keypress(keyascii As Integer)
If keyascii = "13" Then
Command1.SetFocus
End If
End Sub
我的窗体代码
可是我应用后系统提示我类型不匹配。
调试Set g_rs = g_db.OpenRecordset(g_strsql) 系统就在这段代码打黄色提示
谁有空能帮我看看
[此贴子已经被作者于2006-3-17 11:40:44编辑过]