473,472 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

uniqueidentifier in SQL Query

Hi,
I am trying to get the results out of an SQL database where the Id is
equal to a given value. The Id field is a uniqueidentifier this is what I am
trying to do.

SQLQuery = new SqlDataAdapter("SELECT Id, Title, Publication, InsertDate,
NoPages, Colour, Status " +
"FROM Features WHERE Id={guid {" + Request.QueryString[ "id" ] + "}};",
DataBaseConnection);

The Querystring value looks like this "3B9767E0-56DD-49FB-8CC0-79A8FE95CEFF"

I keep getting errors and I would like to find a sample of how to do this.

Thanks
Kenneth.
Nov 18 '05 #1
3 2073
"Kenneth Keeley" <ke*******@hotmail.com> wrote in
news:uT**************@TK2MSFTNGP09.phx.gbl:
The Querystring value looks like this
"3B9767E0-56DD-49FB-8CC0-79A8FE95CEFF"

I keep getting errors and I would like to find a sample of how to do
this.


You need to encapsulate your ID like:

ID='{3B9767E0-56DD-49FB-8CC0-79A8FE95CEFF}'.

Make sure you have the single quotes and curly brackets.

To insert into a GUID field, you need to use the NewID() function to
generate a GUID.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #2
(untested)

Dim cmd As New SqlCommand("SELECT Id, Title, Publication, InsertDate,
NoPages, Colour, Status FROM Features WHERE Id=@guid", DataBaseConnection)

cmd.Parameters.Add(New SqlParameter("@guid", SqlDbType.UniqueIdentifier,
16)).Value = New Guid(Request.QueryString("id").ToString)

Dim da as New SqlDataAdapter(cmd)

Greg

"Kenneth Keeley" <ke*******@hotmail.com> wrote in message
news:uT**************@TK2MSFTNGP09.phx.gbl...
Hi,
I am trying to get the results out of an SQL database where the Id is
equal to a given value. The Id field is a uniqueidentifier this is what I
am
trying to do.

SQLQuery = new SqlDataAdapter("SELECT Id, Title, Publication, InsertDate,
NoPages, Colour, Status " +
"FROM Features WHERE Id={guid {" + Request.QueryString[ "id" ] + "}};",
DataBaseConnection);

The Querystring value looks like this
"3B9767E0-56DD-49FB-8CC0-79A8FE95CEFF"

I keep getting errors and I would like to find a sample of how to do this.

Thanks
Kenneth.

Nov 18 '05 #3
Thanks that fixed it.

"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"Kenneth Keeley" <ke*******@hotmail.com> wrote in
news:uT**************@TK2MSFTNGP09.phx.gbl:
The Querystring value looks like this
"3B9767E0-56DD-49FB-8CC0-79A8FE95CEFF"

I keep getting errors and I would like to find a sample of how to do
this.


You need to encapsulate your ID like:

ID='{3B9767E0-56DD-49FB-8CC0-79A8FE95CEFF}'.

Make sure you have the single quotes and curly brackets.

To insert into a GUID field, you need to use the NewID() function to
generate a GUID.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bernie | last post by:
Greetings, I have 3 servers all running SQL Server 2000 - 8.00.818. Lets call them parent, child1, and child 2. On parent, I create a view called item as follows: CREATE view Item as...
1
by: Vinny | last post by:
Can anyone help me with this strange problem please? I have a stored procedure, with a parameter defined as a uniqueidentifier. The procedure does a select with a number of joins, and filters...
4
by: Jacques Wentworth | last post by:
Hi I have the following problem. I have a SQL Server (2000) Stored Proc that with 4 parameter (one being @UnlockKey uniqueidentifier OUTPUT). I run it from Query Analyzer and the @Key parameter...
5
by: turnstyle | last post by:
Hi all, I'm trying to run a select where a uniqueidentifier/GUID equals a hex, but I don't seem to be getting matches. For example, this query returns the expected record: select * from...
4
by: christopher.secord | last post by:
I have a table that contains articles (as in, newspaper articles, blog articles, whatever). I need to use a column of type uniqueidentifier because one of the requirements is that I be able to...
3
by: SMG | last post by:
Hi all, I created one table with following structure, and bound the same with a DataGird. But I am not able to see any column which is having 'uniqueidentifier' as datatype. Name ...
3
by: Gopal Krish | last post by:
I need to display uniqueidentifier (GUID) from a table in SQL Server into a ASP.NET Web Page (Combo box). I'm using C#. When I tried to display GUIDs in a combo box I get "System.Byte" for all...
2
by: Roy Rodsson via .NET 247 | last post by:
Hi all! I am using a stored procedure in SQL2000 for retrieving fileinformations from a db. the table as an uniqueidentifier for the file information. The stored procedure has a variable...
3
by: qhjghz | last post by:
Hi all, need some help. I have a table called my_table say, and there is a uniqueidentifier field in that table say my_column. When I execute this query, I get back a row select * from my_table...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.