Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Expand a Named Range in 2007 | New Users to Excel | |||
Array as a "named range" - formula ok in cells, but error as "named range" | Excel Discussion (Misc queries) | |||
Named range error | Excel Discussion (Misc queries) | |||
Cannot Expand Named Range - when size of the Range exceeds | Excel Discussion (Misc queries) | |||
Excel Driver Error: Cannot Expand Named Range | Excel Programming |