473,660 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

uniqueidentifie r 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 uniqueidentifie r 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.QuerySt ring[ "id" ] + "}};",
DataBaseConnect ion);

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 2077
"Kenneth Keeley" <ke*******@hotm ail.com> wrote in
news:uT******** ******@TK2MSFTN GP09.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********@rog ers.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("SEL ECT Id, Title, Publication, InsertDate,
NoPages, Colour, Status FROM Features WHERE Id=@guid", DataBaseConnect ion)

cmd.Parameters. Add(New SqlParameter("@ guid", SqlDbType.Uniqu eIdentifier,
16)).Value = New Guid(Request.Qu eryString("id") .ToString)

Dim da as New SqlDataAdapter( cmd)

Greg

"Kenneth Keeley" <ke*******@hotm ail.com> wrote in message
news:uT******** ******@TK2MSFTN GP09.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 uniqueidentifie r 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.QuerySt ring[ "id" ] + "}};",
DataBaseConnect ion);

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********@rog ers.com> wrote in message
news:Xn******** *************** ****@140.99.99. 130...
"Kenneth Keeley" <ke*******@hotm ail.com> wrote in
news:uT******** ******@TK2MSFTN GP09.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********@rog ers.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
4479
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 select * from child1.dbchild1.dbo.Item union all select * from child2.DBChild2.dbo.Item
1
2013
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 within the Where clause using this parameter. (@orderHeader_id uniqueidentifier) SELECT *
4
10153
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 is valued. When I run it from VB.Net it is empty. I tried it with other other datatype and it works fine. Am I doing something wrong? Thanks
5
18934
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 items where itemGUID = '{11111111-2222-3333-4444-555555555555}'
4
2458
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 write the articles out to XML or import them from XML, and references (as in, "for more info read this: 2323-232-90934" have to still work after the export and import). So as a minimum, the table is going to look like this: CREATE TABLE...
3
2188
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 DataType ID uniqueidentifier UID uniqueidentifier
3
7786
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 the items in the combo box. Code : ddSeverity.DataSource = A dataset is returned here; ddSeverity.DataValueField = "Name";
2
9286
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 called fileIds that is oftype varchar. I am putting in a comma separated string with ids (such as:'9B176B0C-CA03-49C9-A2E7-063038E7CF20','9B176B0C-CA03-49C9-A2E7-063038E7CF22','9B176B0C-CA03-49C9-A2E7-063038E7CF23') However, when I execute the sp via...
3
4950
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 where my_column = 'B844EC98-F509-4F41-BC42-301DD22F6A12' But, when I change the string value by changing any of the characters, I get an error stating Server: Msg 8169, Level 16, State 2, Line 1 Syntax error converting from a character string...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8754
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8542
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2760
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 we have to send another system
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.