設(shè)為首頁收藏本站Access中國

Office中國論壇/Access中國論壇

 找回密碼
 注冊

QQ登錄

只需一步,快速開始

返回列表 發(fā)新帖
查看: 2818|回復(fù): 2
打印 上一主題 下一主題

(已解決)想做一個C/S結(jié)構(gòu)的程序,但用ADO連接數(shù)據(jù)庫時,老提示出錯,代碼如下

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
1#
發(fā)表于 2008-2-3 11:31:44 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
以下有幾個錯誤:1、連接字符串屬性無效
2、連接無法用于執(zhí)行此操作,在此上下文中他可能已關(guān)閉或無效
3、數(shù)據(jù)類型不符
Private Sub Command6_Click()
Dim cn As ADODB.Connection
Dim rx As ADODB.Recordset
Dim user_online As Integer
Dim user_id As Integer
Dim user_name As String
user_online = 0
Set cn = New ADODB.Connection
cn.CursorLocation = adUseClient
cn.Open "provider=sqloledb;password=120979120979;" & _
   "user_id=sa;initial catalog=accesstata;data source=wangqiang"
   
Set rx = New ADODB.Recordset
'On Error GoTo Err_Command6_Click
    If IsNull(Text2) Or IsNull(Text4) Then
       MsgBox "沒有輸入用戶名或密碼,請重新輸入", vbInformation, "系統(tǒng)提示"
       Exit Sub
    End If
    rx.Open "select * from user_tbl where user_name=' Text2 ' and user_password=' Text4 '", cn, adOpenStatic, adLockBatchOptimistic, adCmdText

[ 本帖最后由 dreamice01 于 2008-2-27 09:40 編輯 ]
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享分享 分享淘帖 訂閱訂閱
2#
發(fā)表于 2008-2-3 12:21:21 | 只看該作者
看不懂你
Dim user_id As Integer
Dim user_name As String這為什么要聲名變量,從 rx.Open "select * from user_tbl where user_name=' Text2 ' and user_password=' Text4 里看出好象是user_tbl 表中有這字段,這些代碼中好象好多錯誤唉,你最好說明想要達(dá)到什么目地,最好上傳文檔修改

[ 本帖最后由 小鐵匠 于 2008-2-3 12:26 編輯 ]
3#
發(fā)表于 2008-5-7 11:27:01 | 只看該作者
那位能給這方面的例子學(xué)習(xí)學(xué)習(xí)
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則

QQ|站長郵箱|小黑屋|手機版|Office中國/Access中國 ( 粵ICP備10043721號-1 )  

GMT+8, 2024-10-23 08:29 , Processed in 0.111521 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回復(fù) 返回頂部 返回列表