Problem with Select Command

Discussion in 'ASP .Net' started by mick.walker@gmail.com, Nov 9, 2006.

  1. Guest

    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
    , Nov 9, 2006
    #1
    1. Advertising

  2. 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

    --
    http://www.openmymind.net/
    http://www.codebetter.com/


    <> wrote in message
    news:...
    > 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
    >
    Karl Seguin [MVP], Nov 9, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGFiYmxlcg==?=

    select gridview row without using select button?

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 3, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    101,496
    dch31969
    Feb 27, 2009
  2. J. Hall
    Replies:
    2
    Views:
    1,039
    Jeff Thies
    Apr 21, 2004
  3. jas

    select.select() on windows

    jas, Oct 25, 2005, in forum: Python
    Replies:
    4
    Views:
    776
    Maksim Kasimov
    Oct 27, 2005
  4. Mich
    Replies:
    3
    Views:
    484
  5. palmiere
    Replies:
    1
    Views:
    384
    Erwin Moller
    Feb 9, 2004
Loading...

Share This Page