Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

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

$
0
0
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

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>