Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Driver Error: Cannot Expand Named Range
Dear All,
I have created a user data storage with Excel where I am doing insertions only. Sometimes the insertions are done as expected but sometimes they failed and I get the error message from Excel: "Cannot expand named range". I have found a couple of messages about this error but none of them suggested a solution. I include the code I am using at the end of this message. Would anyone have an idea about why Excel manages sometimes to include my data and sometimes not? Could it come from the nature of my data? Let me know if you need more details about my code. I would really appreciate any help Helene. ================================================== ============================== Code for insertion: 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,strval2); 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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Named range error | Excel Discussion (Misc queries) | |||
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) |