LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel Driver Error: Cannot expand named range

Dear All,

I have created a unser data storage linked with Excel
where I would like to do insertions only.
I enclose the code I am using at the end of this message.
Sometimes insertions are done properly but sometimes they failed
and I get the error message from the Excel Driver:
"Cannot expand the named range".
I have found a couple of messages related to this error
but there were no cure for the error.
Would anyone have an idea why sometimes it works and sometimes not?
Could it come from the nature of my data?

Any help is really appreciated.

Best regards,

Helene.

================================================== =============================
Code used for insertions:

char SQLquery[250];
strcpy(SQLquery,
"INSERT INTO ResultTable (Name, File, RunwayNum,
TotalTime, CplexTime, SideCplexTime, SolNum,
InsertedChildNum, ImprovedChildNum, GeneratedChildNum,
Fitness, Unfitness) VALUES (\'");
strcat(SQLquery,str1);
strcat(SQLquery,"\',\'");
strcat(SQLquery,str2);
strcat(SQLquery,"\',\'");
strcat(SQLquery,str3);
strcat(SQLquery,"\',");
strcat(SQLquery,strval1);
strcat(SQLquery,",");
...
strcat(SQLquery,strval9);
strcat(SQLquery,")");

bool result= false;
RETCODE rcode;
HENV henv;
HDBC hdbc;
HSTMT hstmt;
unsigned char longStr[256];
short shortStr;
rcode = ::SQLAllocEnv(&henv);
if(rcode==SQL_SUCCESS) {
rcode = ::SQLAllocConnect(henv,&hdbc);
if(rcode==SQL_SUCCESS) {
rcode = ::SQLDriverConnect(hdbc,0,
(unsigned char *)"DSN=SQLResults",
SQL_NTS,longStr,256,&shortStr, //NULL
SQL_DRIVER_NOPROMPT);
if(rcode==SQL_SUCCESS) {
rcode = ::SQLAllocStmt(hdbc,&hstmt);
if(rcode==SQL_SUCCESS) {
rcode = ::SQLExecDirect(hstmt,
(unsigned char *)SQLquery,SQL_NTS);
if(rcode==SQL_SUCCESS)
result = true;
else
result = false;
::SQLFreeStmt(hstmt,SQL_DROP);
}
::SQLDisconnect(hdbc);
}
::SQLFreeConnect(hdbc);
}
::SQLFreeEnv(henv);
}
return result;
================================================== ==============================
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Expand a Named Range in 2007 Nanette New Users to Excel 2 April 26th 07 10:08 PM
Array as a "named range" - formula ok in cells, but error as "named range" tskogstrom Excel Discussion (Misc queries) 11 December 28th 06 04:44 PM
Named range error Antman Excel Discussion (Misc queries) 3 July 13th 06 02:33 AM
Cannot Expand Named Range - when size of the Range exceeds Snig Excel Discussion (Misc queries) 1 July 7th 05 01:46 PM
Excel Driver Error: Cannot Expand Named Range Helene Pinol Excel Programming 0 April 1st 04 05:39 PM


All times are GMT +1. The time now is 09:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"