社区
数据库
帖子详情
VC中ADO可执行的SQL的长度有限制么?
powerking2
2007-11-07 01:24:22
1、现在需要给数据库中插入记录,由于每一条记录的字段比较多,并且有几个字段的值(字符串)也比较长,大概一条记录最后生成的SQL串有2000多个字符,每次执行插入都回报错,可是我把抱错的SQL语句写进文件中,在查询分析器中执行是正确的。这说明SQL语句是没有问题的,但是如果SQL串短点九不会抱错,怀疑是不是ADO对可执行的SQL串的长度有限制?
2、我是用ADODB::Connection15ptr 这个智能指针的Execute方法直接插入的!
...全文
233
13
打赏
收藏
VC中ADO可执行的SQL的长度有限制么?
1、现在需要给数据库中插入记录,由于每一条记录的字段比较多,并且有几个字段的值(字符串)也比较长,大概一条记录最后生成的SQL串有2000多个字符,每次执行插入都回报错,可是我把抱错的SQL语句写进文件中,在查询分析器中执行是正确的。这说明SQL语句是没有问题的,但是如果SQL串短点九不会抱错,怀疑是不是ADO对可执行的SQL串的长度有限制? 2、我是用ADODB::Connection15ptr 这个智能指针的Execute方法直接插入的!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
13 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
liee96
2007-11-07
打赏
举报
回复
语法好象没有什么问题,你用这个SQL试试再说
insert into temsubject (title,author,authoraffiliation,source,publicationyear,publisher,issn,languages,DocumentType,pages,country,abstract,topic,accessionnumber,databasename ) values ( 'Internet function and Internet addictive behavior ', 'Li, Shih-Ming; Chung, Teng-Ming ', 'Department of Psychology, National Chung-Cheng University, Chia-Yi, Taiwan ', 'Computers in Human Behavior,v 22,16,p 1067-1071,November 2006. ', '2006 ', 'Elsevier Ltd, Oxford, OX5 1GB, United Kingdom ', '0747-5632 ', 'English ', 'Journal article (JA) ', 'p 1067-1071 ', ' ', '(long sentence)', 'Human computer interaction,Internet - Students - Social aspects - Problem solving - Health,Addiction - Interpersonal - Virtual emotional function. ', '06189859669 ', 'EI ')
shakaqrj
2007-11-07
打赏
举报
回复
看的头晕
你把values后面的东西,一点一点地代换
一开始全部换成'1',看看出不出错
然后慢慢来
我只想到这么办了。。。
powerking2
2007-11-07
打赏
举报
回复
走过路过的大侠,都帮忙顶下阿,不胜感激中。。。。。。
powerking2
2007-11-07
打赏
举报
回复
还需要看源码?
那我就贴上来了?
下面是我要执行的SQL语句(有点长阿)
insert into temsubject (title,author,authoraffiliation,source,publicationyear,publisher,issn,languages,DocumentType,pages,country,abstract,topic,accessionnumber,databasename ) values ( 'Internet function and Internet addictive behavior','Li, Shih-Ming; Chung, Teng-Ming ','Department of Psychology, National Chung-Cheng University, Chia-Yi, Taiwan ','Computers in Human Behavior,v 22,16,p 1067-1071,November 2006.','2006','Elsevier Ltd, Oxford, OX5 1GB, United Kingdom','0747-5632','English','Journal article (JA)','p 1067-1071','','Ju [Research on personal characteristics, the behavior of using Internet and Internet addiction for Taiwanese college study. Master thesis. Taiwan, 2000] found the Internet function was related to the severity of Internet addiction, and this study explored the relationship between the Internet function and the Internet addictive behavior. Seventy-six college students were included in this study and had completed the Internet use function questionnaire (social function, informational function, leisure function and the virtual emotional function) and the Chinese Internet Addiction Scale (compulsive use, withdrawal, tolerance, time management problem and interpersonal and health problems). The study revealed not only the relationship between the social function and the index of the Internet dependence (compulsive use, withdrawal, tolerance and the problems in the interpersonal relationship and health), but also the correlation between the information function and the index of the Internet abuse (the problems in the interpersonal relationship and health). We found the social function played the core role in the Internet addictive behavior and the mechanism needs further discussion. © 2004 Elsevier Ltd. All rights reserved.','Human computer interaction,Internet - Students - Social aspects - Problem solving - Health,Addiction - Interpersonal - Virtual emotional function.','06189859669','EI')
----------------------------------------------------------------------------------------------
代码:
::ADODB::Connection15Ptr pConn;
HRESULT hr= pConn.CreateInstance(__uuidof(ADODB::Connection));
if( FAILED(hr))
{
return FALSE;
}
CString ConnStr = GetConnectionString();
hr = pConn->Open((_bstr_t)ConnStr,_bstr_t(L""),_bstr_t(L""),ADODB::adModeUnknown);
VARIANT *vt1 = NULL;
_bstr_t bstr(上面的那个SQL语句);
pConn->Execute(bstr,vt1,ADODB::adCmdText);
zaodt
2007-11-07
打赏
举报
回复
用存储过程
coffeaddice
2007-11-07
打赏
举报
回复
SQL语句 在查询分析器可以执行
但是在vc 操作数据库时 并不一定所有的都可以执行
我上次用ado操作数据库,在查询分析器里可以执行
但是拷贝到vc中 用CString strSQL.format()
格式化执行此语句 错误 因为里面 distinct 不支持
后来自己用vc代码写的了个算法
access和sql在vc中的时间比较条件格式也不一样
建议你就先把insert 拆成短句 然后加条件啊
shakaqrj
2007-11-07
打赏
举报
回复
另外需要看你的比较完整的代码
shakaqrj
2007-11-07
打赏
举报
回复
我以前遇到过更奇怪的现象
insert的字符串莫名其妙的消失一段,如果调换顺序,那就没有错
2000多个字符...汗
本来还想看看你的sql,现在....
算了,还是把你的sql贴出来吧
powerking2
2007-11-07
打赏
举报
回复
各位大侠,看见的都帮忙顶下阿
powerking2
2007-11-07
打赏
举报
回复
我现在是用insert插入数据,我把出错的语句写到 文件中,然后在Sql server的查询分析器中执行都可以阿;我想在查询分析器里可以执行,应该没有语法错误吧
LanglyTiger
2007-11-07
打赏
举报
回复
可能有些语法不支持,楼上的方法不错
coffeaddice
2007-11-07
打赏
举报
回复
有些东西可能不支持
象 distinct 就不可以直接用
而且 有些字符 /\ 之类的不识别
我以前用ado的时候 表名:05/06需求库 查询时就有错误 就是那个/需要处理
这些小问题 你看看 有没有 长度我没有用过那么长的 不知道
或者 你把长句缩短
从最短的开始写
例如: 先写 select * from tab
然后 一点点加条件
看加到哪里的时候出错 再对应找错误
powerking2
2007-11-07
打赏
举报
回复
自己帮自己先顶下
vc
存取jpg图片到数据库
ADO
提供了一套接口,允许我们
执行
SQL
语句、打开记录集、读写数据等。在本示例
中
,"
ado
_jpg"可能是一个包含了数据库操作的源代码文件,其
中
包含创建表、插入图像数据和检索图像数据的函数。 存入图片时,你需要: 1...
db_library.rar_DB-Library_DB_library_db_library
sql
server_
sql
ser
在现代开发环境
中
,虽然ODBC(Open Database Connectivity)和
ADO
.NET等更高级的接口已经广泛使用,但DB-Library对于理解底层数据库操作和熟悉
SQL
Server API仍有其价值。如果你正在处理旧系统或需要在低级别的C/C++...
access数据库读写操作
在
VC
6.0
中
,通过包含必要的头文件(如`#include <atlbase.h>`和`#include <
ado
int.h>`)并初始化
ADO
库,我们可以创建
ADO
对象,如Connection、Command、Recordset等,来实现对Access数据库的操作。 对于Access的基本...
仓库管理系统数据库课程设计
在
VC
中
,我们可以使用ODBC(Open Database Connectivity)或
ADO
(ActiveX Data Objects)来连接和操作
SQL
数据库。通过ODBC,我们可以编写
SQL
命令直接
执行
;而
ADO
则提供了更高级的接口,如Recordset对象,可以直接...
VC
用
ADO
访问数据库全攻略
VC
用
ADO
访问数据库全攻略,介绍了
VC
用
ADO
来访问数据库的各个对象及各方法,很经典,也很实用,很值得一看。 正文一、
ADO
概述
ADO
是Microsoft为最新和最强大的数据访问范例 OLE DB 而设计的,是一个便于使用的应用程序...
数据库
4,017
社区成员
39,806
社区内容
发帖
与我相关
我的任务
数据库
VC/MFC 数据库
复制链接
扫一扫
分享
社区描述
VC/MFC 数据库
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章