Results 1 to 2 of 2

Thread: insert sql query please help this should be easy

  1. #1

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    You need to include the single qoute in your SQL statement:
    This because you declara as String.
    Code:
     
    SQL = "INSERT INTO CandidateHistory(CandidateHistoryID)VALUES ('" & CandidateIdNumber & "')"
    Originally posted by johnnyboy23
    this is my statement

    Code:
    SQL = "INSERT INTO CandidateHistory(CandidateHistoryID)VALUES (" & CandidateIdNumber & ")"
    but the value that i want should come from my varible because that value changes all the time
    called
    Code:
    dim CandidateIdNumber as string
    this this correct????

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Note that the difference between

    INSERT INTO Table1 (FieldName) SELECT Table2.FieldName2 FROM Table2;

    and

    INSERT INTO Table1 (FieldName) VALUES (SomeValue);

    is that the former is a multi record append query and the latter is for one record only.

    You may be having problems with data types since you appear to be adding a numeric value but you have declared the variable as a string. Chris is right when he says that you need to enclose the string in quotes, but if it is meant to be a numeric value you should explicitly do a type cast (i.e. CInt(CandidateIdNumber))

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

Posting Permissions

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



Click Here to Expand Forum to Full Width