Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SQL Statement and quotes

    Background:

    I place a batch of names and ID numbers into a table using the following SQL statement:
    INSERT INTO tablename (

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: SQL Statement and quotes

    Why would you have quotes around the field names? You definitely don't need them in Access. I'm assuming the quotes around the values represent strings. You can just embed double quotes in the SQL instead of single quotes, which takes care of the apostrophe problem. Of course, that won't work in SQL Server, but it does in Access. If you're building the SQL in code, you can use three double quotes in sequence to represent a single instance of a double quote (say that three times fast [img]/S/grin.gif[/img]).
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SQL Statement and quotes

    They are strings which I'm using.

    Basically, I have an array of 5 strings which make up a record in a table.

    Is there any other possible way of inserting the record into the table without using an INSERT statement?

    James

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: SQL Statement and quotes

    Excuse me? Your strings are the values you want to insert, right? So what's the problem with the insert statement? The alternative is to open a recordset and use AddNew to add a new record so you can populate the fields with the string values. However, it's slower.
    Charlotte

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SQL Statement and quotes

    Yes. Some of the strings contain apostraphes (single quotes) and some of the strings have a length of 127 and for some reason the SQL statement chops some of the length of and therefore falls over.

    I'll try a recordset suggestion.

    Thanks for the help so far!

    James

Posting Permissions

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