Results 1 to 11 of 11

Thread: Insert problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2001
    Location
    Kuala Lumpur
    Posts
    212

    Insert problem

    Hi
    Why does insert with these character ( ' ! ) is not allow? It prompts me any Syntax Error whenever i have these characters. Please help.. Thank you.
    Is there anything wrong the way i insert data below?
    VB Code:
    1. '" & text1.text & "'
    kC

  2. #2
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    What you've got is fine, as long as the rest of the line is OK.
    Post the whole query.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2001
    Location
    Kuala Lumpur
    Posts
    212
    Hi rj, i can't post the entire code because i am dealing with more than 50 fields. Just for ur info, i am using Access as my database.

    VB Code:
    1. SQL = "INSERT INTO tb_master (policyno,insuredname) VALUES ('" & TxtPoliNo.Text & "', '" & txtname.Text & "')"
    kC

  4. #4
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    That looks fine.
    However, if the text boxes contain certain 'special' characters, you may have problems.
    But I thought it would be OK like that. Try putting a / before certain characters before adding it to the DB...
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  5. #5
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    If your fields are numerics.... then you don't need the '
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  6. #6
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Ah, yes. That's a possibility too.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2001
    Location
    Kuala Lumpur
    Posts
    212
    hi rjlohan,

    U mean this way?
    John/'s

    What can the flash does?

    MC BRAIN, i know i do not need ' for numeric fields. It still give the same Error when i try to input special character like ' ! .

    What other possibilities?
    kC

  8. #8
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Ok... so you're problem is when you're trying to insert this:

    "INSERT INTO Table VALUES( '" & "O'Donnel" & "')"

    Isn't it?
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  9. #9
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    You can't put those type of characters into a numeric field.

    But the slash is a special character, which you use to precede certain other characters so they can be put in the DB correctly.

    // = /
    /' = '
    /" = "

    There are others. It may or may not work. I'm not sure.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Oct 2001
    Location
    Kuala Lumpur
    Posts
    212
    Mc Brain, u are right. i had that problem.

    rjlohan, it is text field but it still can't accpet special character like i mentioned early on
    kC

  11. #11
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Try the other slash then: \
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

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