Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2006
    Location
    Cairo, Egypt
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Insert comma in MS Access

    Hello everybody...

    I am trying to insert a string variable with INSERT SQL statement into MS Access database.

    This variable contains a comma(,).

    When execute SQL statement, it cause a syntax error, although I can insert commas in database directly without any problem.

    Is there a solution for this error ?

    Thank you for any help.
    Khaled Mahmoud
    Web, Flash, Games developer.
    JavaScript reference VBScript reference ASP reference

  • #2
    Regular Coder Baleric's Avatar
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    332
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can you show code...

    or you can replace the comma before it goes intot the database and then when you call it out you can replace it again, or stick it in quotes...

    show your code its alot easier

  • #3
    New Coder
    Join Date
    Jul 2004
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you looking for this? This should let you insert data into an access database that contains commas.

    Code:
    formvalue=replace(request.form("formvalue"),"'","''")

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by npala2001 View Post
    Are you looking for this? This should let you insert data into an access database that contains commas.

    Code:
    formvalue=replace(request.form("formvalue"),"'","''")
    That code does nothing to effect commas.

  • #5
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    commas should be inserted no problem, just make sure that for any varChar strings, to use single quotes around the data, like '" & string & "'
    Last edited by angst; 01-30-2007 at 04:07 PM.


  •  

    Posting Permissions

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