Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to insert records into Excel table

Status
Not open for further replies.

SatishPutcha

Programmer
Mar 12, 2002
256
IN
Hello Everybody

I am using VC++ 6.0 and trying to insert records into an Excel 2003 sheet using ODBC.

The table has been created and the ranges named but it is only inserting one record and then I am getting rhe "cannot expand named range" error.

Now when I change the range definition I am getting a "spreadsheet is full" error.

I am not sure what is going wrong and any help would be greatly appreciated.

Here is my code for inserting:

Code:
CDatabase db1;
if(!db1.IsOpen())
db1.Open(NULL,FALSE,FALSE,_T("ODBC;Driver={Microsoft Excel Driver (*.xls)};DSN='';DBQ=TT_Database.XLS;ReadOnly=False"),TRUE);

strSQL1 = "INSERT INTO tbl_AllCaptured(TickerSymbol,FIELD_PRICE, FIELD_VOLUME, DateOfCapture) VALUES('GE',25.57,45,#10/10/2000#)";

db1.ExecuteSQL(strSQL1);
db1.Close();

Thanks & Regards
Satish Kumar Putcha
 
using SQL/ODBC is not the ebst method for working with excel. Try by using Excel.Sheet COM object

Ion Filipski
1c.bmp
 
Thank you Ion for your reply.


I was stuck getting this application up and running so could not reply soon.

Is the use of the Excel COM reliable? I mean can I add/delete/edit records with the same asssurance as I feel there is when using ODBC with SQL queries?

Regards
Satish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top