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