| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 500 人关注过本帖
标题:类型匹配问题%
只看楼主 加入收藏
dlb2000
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-3-16
收藏
 问题点数:0 回复次数:4 
类型匹配问题%

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编辑过]

搜索更多相关主题的帖子: 类型 
2006-03-17 11:39
quickbird
Rank: 1
等 级:新手上路
帖 子:72
专家分:0
注 册:2006-1-1
收藏
得分:0 
将g_strsql = "select * from systeminfo where 名称='" & Text1.Text & "' and 密码='" & Text2.Text & "'"

改成:

g_strsql = "select * from systeminfo where 名称='" & Text1.Text & " and 密码='" & Text2.Text & "'"
即可。

算浮生事,瞬息光阴,锱铢名宦。 正欢笑,试恁暂时分散。 却是恨雨愁云,地遥天远。
2006-03-17 12:56
dlb2000
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-3-16
收藏
得分:0 

还是不可以……
语法照你说的会语法错误

2006-03-17 13:12
wsn
Rank: 2
等 级:新手上路
威 望:5
帖 子:321
专家分:0
注 册:2006-2-9
收藏
得分:0 
Public g_rs As Recordset
改成

Public g_rs As new Recordset

试试验

已婚男人!没事请勿打扰·老婆格言:①不准對她耍酷 ②不准讓她吃醋 ③吵架我要讓步 ④揍我我要挺住⊙⊙
2006-03-17 17:21
VBSTAR
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-3-17
收藏
得分:0 
真难呀!将字符串语句中的=改成like试试

2006-03-17 23:17
快速回复:类型匹配问题%
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015913 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved