Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Passing ID's in SQL

Reply
Thread Tools

Passing ID's in SQL

 
 
Andrew Banks
Guest
Posts: n/a
 
      02-15-2004
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


 
Reply With Quote
 
 
 
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      02-15-2004
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" <(E-Mail Removed)> wrote in message
news:CnPXb.5031$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Andrew Banks
Guest
Posts: n/a
 
      02-15-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:CnPXb.5031$(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      02-18-2004
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" <(E-Mail Removed)> wrote in message
news:LdRXb.5152$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:CnPXb.5031$(E-Mail Removed)...
> > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing an array from FORTRAN to C then passing it within C andReturning it to FORTRAN deadpickle C Programming 1 11-07-2010 02:38 PM
Passing parameters to an executable vs. passing them to a server Ramon F Herrera C++ 8 09-13-2009 02:48 AM
passing copy of a pointer to a variable vs passing the copy pereges C Programming 7 06-01-2008 02:36 PM
SQL Reference, SQL Queries, SQL help ecoolone ASP .Net 0 01-03-2008 10:58 AM
Passing by const & and returning a temp vs passing by value and returningit Victor Bazarov C++ 25 03-23-2005 04:24 PM



Advertisments