![]() |
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; ================================================== ============================== |
All times are GMT +1. The time now is 03:06 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com