Passing ID's in SQL

Discussion in 'ASP .Net' started by Andrew Banks, Feb 15, 2004.

  1. Andrew Banks

    Andrew Banks Guest

    I'm using guid to generate primary keys for my SQL server DB

    I'm now trying to query the DB but keep getting errors. It seems to be
    erroring when passing the ID and it's always around a hyphen in the sring
    I'm passing

    Eg.

    WHERE ID = '24646a31-c088-41da-b93c-32174588da48' errors near a31
    WHERE ID = 'f7a9b89a-cbf6-4f40-aafe-7a861214ddcc' errors near f40
    WHERE ID = '30328414-3e2a-4244-9163-e0384afe8b5a' errors near a

    Can anyone help on this?

    Are you supposed to escape the - in some way?

    Thanks
     
    Andrew Banks, Feb 15, 2004
    #1
    1. Advertising

  2. Let's see how you're setting up the SQL in code. I suspect you're not using
    a Command object and parameters.

    --
    ____________________________________
    William (Bill) Vaughn
    Author, Mentor, Consultant
    Microsoft MVP
    www.betav.com
    Please reply only to the newsgroup so that others can benefit.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    __________________________________

    "Andrew Banks" <> wrote in message
    news:CnPXb.5031$...
    > I'm using guid to generate primary keys for my SQL server DB
    >
    > I'm now trying to query the DB but keep getting errors. It seems to be
    > erroring when passing the ID and it's always around a hyphen in the sring
    > I'm passing
    >
    > Eg.
    >
    > WHERE ID = '24646a31-c088-41da-b93c-32174588da48' errors near a31
    > WHERE ID = 'f7a9b89a-cbf6-4f40-aafe-7a861214ddcc' errors near f40
    > WHERE ID = '30328414-3e2a-4244-9163-e0384afe8b5a' errors near a
    >
    > Can anyone help on this?
    >
    > Are you supposed to escape the - in some way?
    >
    > Thanks
    >
    >
     
    William \(Bill\) Vaughn, Feb 15, 2004
    #2
    1. Advertising

  3. Andrew Banks

    Andrew Banks Guest

    Bill,

    Your comments made me re-check what I'd done. I had built the sql ok but
    missed out the ' and ' either side of the ID I was passing.

    I guess we all do it - look at our code that long we miss even the most
    obvious of mistakes.

    "William (Bill) Vaughn" <> wrote in message
    news:...
    > Let's see how you're setting up the SQL in code. I suspect you're not

    using
    > a Command object and parameters.
    >
    > --
    > ____________________________________
    > William (Bill) Vaughn
    > Author, Mentor, Consultant
    > Microsoft MVP
    > www.betav.com
    > Please reply only to the newsgroup so that others can benefit.
    > This posting is provided "AS IS" with no warranties, and confers no

    rights.
    > __________________________________
    >
    > "Andrew Banks" <> wrote in message
    > news:CnPXb.5031$...
    > > I'm using guid to generate primary keys for my SQL server DB
    > >
    > > I'm now trying to query the DB but keep getting errors. It seems to be
    > > erroring when passing the ID and it's always around a hyphen in the

    sring
    > > I'm passing
    > >
    > > Eg.
    > >
    > > WHERE ID = '24646a31-c088-41da-b93c-32174588da48' errors near a31
    > > WHERE ID = 'f7a9b89a-cbf6-4f40-aafe-7a861214ddcc' errors near f40
    > > WHERE ID = '30328414-3e2a-4244-9163-e0384afe8b5a' errors near a
    > >
    > > Can anyone help on this?
    > >
    > > Are you supposed to escape the - in some way?
    > >
    > > Thanks
    > >
    > >

    >
    >
     
    Andrew Banks, Feb 15, 2004
    #3
  4. I have my wife (generally computer agnostic) try all my samples. She usually
    breaks them in ways no one could imagine. Isn't that what "extreme"
    programming is all about? Another set of eyes always helps.
    Glad you got it working.

    --
    ____________________________________
    William (Bill) Vaughn
    Author, Mentor, Consultant
    Microsoft MVP
    www.betav.com
    Please reply only to the newsgroup so that others can benefit.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    __________________________________

    "Andrew Banks" <> wrote in message
    news:LdRXb.5152$...
    > Bill,
    >
    > Your comments made me re-check what I'd done. I had built the sql ok but
    > missed out the ' and ' either side of the ID I was passing.
    >
    > I guess we all do it - look at our code that long we miss even the most
    > obvious of mistakes.
    >
    > "William (Bill) Vaughn" <> wrote in message
    > news:...
    > > Let's see how you're setting up the SQL in code. I suspect you're not

    > using
    > > a Command object and parameters.
    > >
    > > --
    > > ____________________________________
    > > William (Bill) Vaughn
    > > Author, Mentor, Consultant
    > > Microsoft MVP
    > > www.betav.com
    > > Please reply only to the newsgroup so that others can benefit.
    > > This posting is provided "AS IS" with no warranties, and confers no

    > rights.
    > > __________________________________
    > >
    > > "Andrew Banks" <> wrote in message
    > > news:CnPXb.5031$...
    > > > I'm using guid to generate primary keys for my SQL server DB
    > > >
    > > > I'm now trying to query the DB but keep getting errors. It seems to be
    > > > erroring when passing the ID and it's always around a hyphen in the

    > sring
    > > > I'm passing
    > > >
    > > > Eg.
    > > >
    > > > WHERE ID = '24646a31-c088-41da-b93c-32174588da48' errors near a31
    > > > WHERE ID = 'f7a9b89a-cbf6-4f40-aafe-7a861214ddcc' errors near f40
    > > > WHERE ID = '30328414-3e2a-4244-9163-e0384afe8b5a' errors near a
    > > >
    > > > Can anyone help on this?
    > > >
    > > > Are you supposed to escape the - in some way?
    > > >
    > > > Thanks
    > > >
    > > >

    > >
    > >

    >
    >
     
    William \(Bill\) Vaughn, Feb 18, 2004
    #4
    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. Victor Bazarov
    Replies:
    25
    Views:
    964
    E. Robert Tisdale
    Mar 23, 2005
  2. ecoolone
    Replies:
    0
    Views:
    797
    ecoolone
    Jan 3, 2008
  3. pereges
    Replies:
    7
    Views:
    459
    pereges
    Jun 1, 2008
  4. Ramon F Herrera
    Replies:
    8
    Views:
    506
    Pascal J. Bourguignon
    Sep 13, 2009
  5. deadpickle
    Replies:
    1
    Views:
    1,083
    Jens Thoms Toerring
    Nov 7, 2010
Loading...

Share This Page