Consulting

Results 1 to 5 of 5

Thread: Sleeper: Getting error in SQL

  1. #1
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location

    Sleeper: Getting error in SQL

    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.

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Well you are actually adding a ' in your SQL statement.

  3. #3
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    even when i remove the apostrophe in the sql command...the apostrphe still appears in the data base sheet...

  4. #4
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    xCrdts is a variable defined as single or double in the master sheet
    But how is it defined/declared in your code?

  5. #5
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •