Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using DAO in which I am trying to execute an SQL query in MS ACCESS 2007 containing more than 260 characters. And as such the query fails to execute. I need to execute an query which is more than 260 characters in length. I am using C/C++. Kindly help.

C++
static DAO::_DBEngine* pEngine = NULL;
static DAO::DatabasePtr pDbPtr = NULL;

_bstr_t dbFile ="C:\\ObjectInfo.accdb";

hr = CoCreateInstance(
        __uuidof(DAO::DBEngine),
        NULL,
        CLSCTX_ALL,
        IID_IDispatch,
        (LPVOID*)&pEngine);

if (SUCCEEDED(hr) && pEngine)
	 pDbPtr = pEngine->OpenDatabase(dbFile);

/*
....Created table
*/
 
_bstr_t query = "INSERT INTO mytable VALUES( 4,0,12289,0,0,0,0,0,0,0,0,0,0,1,0,"C:\TEST1\fld_L1","null","null","null","null")";

pDbPtr->Execute(query);


The above query will execute successfully if the length of query is <260 chars. But Fails on larger query.
Thank you.
Posted
Updated 2-Oct-11 23:39pm
v5
Comments
Mehdi Gholam 29-Sep-11 4:51am    
DAO has no such limits on query size, you must be mistaken.
André Kraak 29-Sep-11 15:56pm    
Please share any relevant code with us, seeing the code might us help understand the problem you are facing.

If you wish to change your question use the Improve Question button.

1 solution

Hi guys, I solved my above problem by making following changes:

C#
DAO::_QueryDefPtr temp;
temp = pDbPtr->CreateQueryDef("",query);
temp->Execute();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900