CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Database

  1. #1
    Join Date
    Aug 2001
    Posts
    31

    Database

    I want to know whether character pipe(|) can be inserted into access database using vb.Becos when i am trying to insert a | its giving me a syntax error


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Database

    Pipr can be inserted into the text field. make sure that you have quotes around it.

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Aug 2001
    Posts
    31

    Re: Database


    I have written Sql statement this way

    strsql = "Insert into questionnaire (questionnaire_name) values ( " & "'" & str & "'" & " )"

    and value of str="ssssssssss|"

    which is giving me syntax error for |
    if i remove | from the string its fine




  4. #4
    Join Date
    Aug 2000
    Location
    England
    Posts
    185

    Re: Database

    Hello,

    try using the ascii representation of the pipe, i.e

    str="ssssssssss"
    strsql = "Insert into questionnaire (questionnaire_name) values ( " & "'" & str & "'" & chr(124) & "'" & "'" & " )"

    Andrew






  5. #5
    Join Date
    Aug 2001
    Posts
    31

    Re: Database

    no this is appendinding another | to it and giving an error


  6. #6
    Join Date
    Aug 2000
    Location
    England
    Posts
    185

    Re: Database

    Did you take the original one off the string first.

    Use mid (str, 1, len(str) -1) & chr(124).

    Failing that replace the | with another character that will not be used, such as \ or :, when it comes to reading them you can easily translate them back.

    Andrew


  7. #7
    Join Date
    Jul 2001
    Location
    Salzburg, Austria
    Posts
    126

    Re: Database

    hi!
    I have just tried to insert a "|" with VB in Access (the way you suggested) and it works fine. Which kind of sintax error do you get, from the ODBC driver?
    Jaime.


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

Featured