Results 1 to 5 of 5

Thread: Vb sql

  1. #1
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303

    Unanswered: Vb sql

    hi
    It is possible to write a sql parameter not a stored procedure using vb just like in delphi am using before?

    Thanks ...

  2. #2
    Join Date
    Nov 2004
    Posts
    108
    I really don't understand what you need but you can write any SQL valid statement in ADO with the conn.execute or rec.Open as you would do in the database program e.g. Query Analyzer
    to err is human ; to really mess things up requires a computer

  3. #3
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303
    Hi,
    What I need is a sql statement that prevent the error when the user input with a char '. Example shown below.

    Henry's Restaurant

    The error occur when the inputed value has a quotation.


    Thanks...

  4. #4
    Join Date
    Dec 2004
    Location
    Coon Rapids, Minnesota
    Posts
    41
    Ok, I struggled with this for a while when I was trying to use the SQL to insert the record. I ended up just using the VB to insert the record, but if you absolutely have to do it with SQL, I believe that you have to either send your string to SQL in double quotes (which i think only works with some SQL clients) or the other option would be to pass your string to a fuction first and check each character to see if it is a ' and if it is prefix it with another '.

    Hope this makes sense

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Preprocessing the string to handle the apostrophes is the easy answer to this specific problem (a short function to scan the string and prefix any apostrophe with another apostrophe). Using ADO instead of writing your own INSERT or UPDATE statements is an easy way to get this functionality automagically.

    Thinking in more generic terms, I think you are looking for VB's ON ERROR statement.

    -PatP

Posting Permissions

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