注册 登录
编程论坛 VB6论坛

编程遇到点问题,求大神指教!!

dapengvb 发布于 2012-12-15 14:44, 330 次点击
Private Function checkuser() As Boolean

Dim rs As ADODB.Recordset

Set rs = New ADODB.Recordset

rs.cursortype = adopenkeyset

rs.locktype = adLockOptimistic

sqlconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\yyjxc.mdb"

rs.Open "Select * from [user] where name = '" & Trim(suser) & "'and password='" & Trim(spassword) & "'", sqlconnection

If rs.RecordCount = 1 Then

checkuser = True

Else

checkuser = False

End If

End Function

上面代码运行后,无论正确与否,rs.RecordCount 的返回值总不是1,求好心人指教!
1 回复
#2
风吹过b2012-12-16 10:58
sqlconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\yyjxc.mdb"

rs.Open "Select * from [user] where name = '" & Trim(suser) & "'and password='" & Trim(spassword) & "'", sqlconnection

这二句错了。

sqlconnection  这生成的 数你据连接字串,并没有打开数据库。
而下面这句需要的引用 数据库连接对象,而不是数据连接字串。

你自已百度一下吧
1