Problem with Select Command

  • Thread starter Thread starter mick.walker
  • Start date Start date
M

mick.walker

Hi all,
I need some help with a simple select query using MS SQL Server 2005.
The problem I am having is due to the contents of the table, it can
contain names which use punctuation marks such as:

S'Algar
Olhos D'Agua
Praia D'Oura
etc.etc
This is breaking my SQL Queries. I select the data using

Dim command As New SqlCommand("Select * from Navigation where
Keyword='" & Index & "'", connection)
and simply read the data returned by the query, into a dataset.
I'd be grateful for any help offered

Kind Regards
 
Parameterize your queries..it'll be safer and likely fix your bug.

"SELECT * FROM Navigation WHERE Keyword = @Index"
command.Parameters.Add("@Index", SqlDbType.VarChar, 128).Value = index


the VarChar and 128 parts I made up, you'll need to change the to whatever
actual type/length you want.

Karl
 
Back
Top