设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 2607|回复: 2
打印 上一主题 下一主题

(已解决)想做一个C/S结构的程序,但用ADO连接数据库时,老提示出错,代码如下

[复制链接]
跳转到指定楼层
1#
发表于 2008-2-3 11:31:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
以下有几个错误:1、连接字符串属性无效
2、连接无法用于执行此操作,在此上下文中他可能已关闭或无效
3、数据类型不符
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, "系统提示"
       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#
发表于 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 表中有这字段,这些代码中好象好多错误唉,你最好说明想要达到什么目地,最好上传文档修改

[ 本帖最后由 小铁匠 于 2008-2-3 12:26 编辑 ]
3#
发表于 2008-5-7 11:27:01 | 只看该作者
那位能给这方面的例子学习学习
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-16 18:18 , Processed in 0.104502 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表