PDA

View Full Version : Sleeper: Getting error in SQL



asingh
08-07-2005, 05:25 AM
Hi ,
I have two excel sheets....and I am transferring data from the master excel sheet to a data base excel sheet [which is a closed sheet] using SQL..embeded as VBA code. The data is reaching the data base sheet fine..but the problem I am facing that, when I open the data base sheet, all the data is showing up as string literals. For example if I send the data 3.23 via sql to the data base sheet...I see the data as '3.23 in the data base sheet. All data points in the data sheet have an apostrophe in front of them. Even if the data is defined as decimal data type in the master sheet..it is still showing up as string literals in the data base sheet. The SQL syntax that I am using is:


rstworkbook.Open strSQL, connectString

Where rstworkbook is an object, strSQL is the sql command line, and connectString is the string with the connection properties for the data base sheet.


strSQL = INSERT INTO [userdata$] ([Credits]) VALUES '" & xCrdts "'

xCrdts is a variable defined as single or double in the master sheet.

Norie
08-07-2005, 07:01 AM
Well you are actually adding a ' in your SQL statement.

asingh
08-07-2005, 10:38 AM
even when i remove the apostrophe in the sql command...the apostrphe still appears in the data base sheet...

Norie
08-07-2005, 11:35 AM
xCrdts is a variable defined as single or double in the master sheet

But how is it defined/declared in your code?

asingh
08-07-2005, 11:45 AM
the sql command line is a string & the variable that I am transferring via SQL is defined as single..i.e.


DIM sqlSTR as String
DIM xCrdts as Single