Results 1 to 21 of 21

Thread: [RESOLVED] Invalid SQL Statement in my VB .NET Code - Can't figure it out

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    295

    Resolved [RESOLVED] Invalid SQL Statement in my VB .NET Code - Can't figure it out

    Hello all,

    I do not know enough about SQL to solve this on my own and Google was unexpectedly not helpful.

    I have to do a search on a captured field that contains a ' (Tick-mark).

    Example...

    Dim Company_Code As String.

    I Read the File.....
    Then Load the values...
    Eventually the field Company_Code has a value of "Moody's"

    The formatted SQL Statement looks like this...

    'SELECT Client_Number from clients where client_name=Moody's'
    Then <Error>
    The extra Tick-Mark trips up the statement

    When I format my SQL Statement I error out because of the Tickmark. I can not figure a way to format it so SQL will accept it.
    When I test all my SQL Statements in SQL Server Studio Manager 2012 I can not format the statement with double quotes.

    SELECT Client_Number from clients where client_name="Moody's" <== SQL does not like this
    SELECT Client_Number from clients where client_name='Some other company name' <== SQL likes this

    Does anyone know of a way to fix my formatting issue?

    Thanks,

    -NJ
    Last edited by NJDevils28; May 16th, 2013 at 08:20 AM.

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