Dim rs As New Recordset '定义记录集
Dim conn As New Connection '定义连接对像
Dim conStr As String
conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\vb练习\myQQ\QQ.mdb;Persist Security Info=False"
Set rs = New Recordset
Set conn = New Connection
conn.ConnectionString = conStr
conn.Open
Set rs.ActiveConnection = conn
rs.CursorLocation = adUseClient '返回客户端游标
rs.Source = "select qqid from userinfo where qqid= '" & Val(Combo1.Text) & " ' and _ password='" & txtPassword.Text & " '"
rs.Open , , adOpenStatic, adLockOptimistic一运行就提示:表达式中类型不匹配,我怀疑问题出在这一句上:
rs.Source = "select qqid from userinfo where qqid= '" & Val(Combo1.Text) & " ' and _ password='" & txtPassword.Text & " '"
因为我把它换为一个简单的语句:select * from userinfo 就没错了,请问我错在哪里
Dim conn As New Connection '定义连接对像
Dim conStr As String
conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\vb练习\myQQ\QQ.mdb;Persist Security Info=False"
Set rs = New Recordset
Set conn = New Connection
conn.ConnectionString = conStr
conn.Open
Set rs.ActiveConnection = conn
rs.CursorLocation = adUseClient '返回客户端游标
rs.Source = "select qqid from userinfo where qqid= '" & Val(Combo1.Text) & " ' and _ password='" & txtPassword.Text & " '"
rs.Open , , adOpenStatic, adLockOptimistic一运行就提示:表达式中类型不匹配,我怀疑问题出在这一句上:
rs.Source = "select qqid from userinfo where qqid= '" & Val(Combo1.Text) & " ' and _ password='" & txtPassword.Text & " '"
因为我把它换为一个简单的语句:select * from userinfo 就没错了,请问我错在哪里
必须对txtPassword.Text处理
rs.Source = "select qqid from userinfo where qqid= '" & Val(Combo1.Text) & " ' and _ password='" & iif(trim(txtPassword)="",0,txtPassword)& " '"
& " password='"
应该是这样吧
" password='" & txtPassword.Text & " '"
字符串换行连接用 & _
噢,不好意思,没玩过Access,所以不了解