您的位置:程序门 -> vb -> 数据库(包含打印,安装,报表)



sql语句查询错误


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


sql语句查询错误
发表于:2007-02-06 14:39:09 楼主
dim   sql   as   string
dim   str   as   string
dim   path   as   string
path   =   app.path
if   right(str,   1)   <>   "\ "   then
str   =   str   +   "\ "
else
str   =   str
end   if
str   =   "provider=microsoft.jet.oledb.4.0;;persist   security   info=false "
sql   =   "select   *   from   information "

adodc1.recordset.open   sql,   str,   adopenkeyset,   adlockpessimistic

我想在information中查询所有字段、记录,使用的是adodc,执行后提示“对象打开时,不允许操作”,请问怎么回事啊?
发表于:2007-02-06 15:09:591楼 得分:0
dim   str   as   string
dim   path   as   string
path   =   app.path
str   =   path
if   right(str,   1)   <>   "\ "   then
str   =   str   +   "\ "
else
str   =   str
end   if
str   =   "provider=microsoft.jet.oledb.4.0;;persist   security   info=false;data   source= "   &   str   &   "studentsinfo.mdb "

adodc1.recordset.open   "select   *   from   information ",   str,   adopenstatic,   adlockoptimistic

使用的vb6+adodc+access。
发表于:2007-02-06 15:57:192楼 得分:0
救急啊,来帮帮我啊!!谢谢了。
发表于:2007-02-06 17:17:183楼 得分:0
运行后提示   实时错误3705,对象打开时,不允许操作。
发表于:2007-02-06 17:19:324楼 得分:0
access被独占使用
发表于:2007-02-06 17:21:055楼 得分:0
那怎么释放呢?
发表于:2007-02-06 17:42:256楼 得分:0
你是不是同时打开了机器上的access阿,把那个数据库关掉再看看
发表于:2007-02-06 17:44:547楼 得分:0
access没有打开,只是已经被这个adodc用了,我想在这个基础上根据条件筛选一下字段。
发表于:2007-02-06 21:08:168楼 得分:0
快来解答阿
发表于:2007-02-06 21:38:249楼 得分:0
高手们在哪里呢
发表于:2007-02-08 10:35:3910楼 得分:0
如果用adodc控件不用编写任何代码就可以使用了
发表于:2007-02-08 10:45:2111楼 得分:0
把你的数据库加上试试
发表于:2007-02-08 11:51:2112楼 得分:0
是不是adodc1.recordset重复打开了,你open之前close试试
发表于:2007-02-08 12:44:3313楼 得分:0
改种写法吧,我也碰到过,改了下写法就好了。
发表于:2007-02-08 14:34:4414楼 得分:0
adodc1.connectionstring   =   str
adodc1.recordsource   =   sql
adodc1.refresh
发表于:2007-02-13 14:35:0515楼 得分:0
这不应该是查询语句的错误,用adodc控件,不用写任何代码就可以实现,估计是楼主操作失误。主要是connectionstring属性和recordsource属性的设置:
假如:“connectionstring”设为provider=microsoft.jet.oledb.4.0;data   source=e:\mytest\vb\ftptest\database\txtdata.mdb;persist   security   info=false
“recordsource”设为select   *   from   information,然后在界面上放一个datagrid并将datagrid的datasource设为adodc1,运行程序就可以看见表中的数据了。


发表于:2007-02-13 14:37:4016楼 得分:0
我给出一段不用控件,用代码写的数据库连接你看看

dim   adocomm   as   adodb.command
        dim   rs   as   adodb.recordset
       
        linenum   =   0
        txtname   =   "20070212 "
        sqlrecordnum   =   "select   recordcode   from   ftpdata   where   recordcode   like   ' "   &   txtname   &   "% '   order   by   recordcode "
        if   adocomm   is   nothing   then
              set   adocomm   =   new   adodb.command
              adocomm.commandtype   =   adcmdtext
              adocomm.activeconnection   =   adoconn
        end   if
       
        if   rs   is   nothing   then
              set   rs   =   new   adodb.recordset
        end   if
        rs.open   sqlrecordnum,   adoconn,   adopenstatic,   adlockreadonly,   adcmdtext
        recordnum   =   rs.recordcount


快速检索

最新资讯
热门点击