ado读取数据,问题应该不难。代码贴出来了,请大家看看那里错了

gao 2006-02-22 04:58:00
Private Sub ImgIn_Click()
On Error GoTo eRRorHandle
Dim GetRight As New ADODB.Recordset
User_Name = UserName.Text
User_Pswd = Password.Text
Dim strsql As String
strsql = "select userid from app.users where username = '" & User_Name & "' and userpassword = '" & User_Pswd & "'"
Call Dbconnection
Set GetRight = New Recordset '●●注意这里出错了。
With GetRight
Set .ActiveConnection = cnMain
.Open strsql, , adOpenDynamic, adLockOptimistic
End With
If Not GetRight.EOF() Then
If InStr(1, GetRight.Fields("Privilege").Value, RightAll) > 0 Then
Unload FirstForm
frm1.Show
Else
MsgBox "无此权限!", vbCritical, "错误提示"
End If
Else
MsgBox "用户名称或口令错!", vbCritical, "错误提示"
End If
Exit Sub
eRRorHandle:
MsgBox "与数据库的连接失败!", vbCritical, "错误提示"
End Sub


Public Sub Dbconnection()
szConn = "Provider=MSDAORA.1;Password=123123;User ID=app;Data Source=app;Persist Security Info=True"
Set cnMain = New Connection
cnMain.Open szConn
End Sub
...全文
92 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
tony62 2006-02-22
  • 打赏
  • 举报
回复
Call Dbconnection
这句没有出错吗?我觉得应该是Set cnMain = New adodb.Connection

不过也可能问题的关键不在这里,你看看工程-引用里有没有引用ado呢
再有就是楼上的同志说的在recordset前加个adodb了


还有我给你介绍个下载电子书的好地方:
http://www.netyi.net/in.asp?id=tongyanlin
faysky2 2006-02-22
  • 打赏
  • 举报
回复
Set GetRight = New Recordset '●●注意这里出错了。
----------------------------------------------------------
改为
Set GetRight = New ADODB.Recordset '●●注意这里出错了。

就OK了

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧