Wednesday, March 21, 2012

passing a GUID in the querystring

I need to pass a GUID into a page via the QueryString. If I do:

Dim myGUID as GUID
GUID = Request.QueryString("myGUID")

It won't run, and says that a value type of string cannot be converted to a GUID. I can't retype myGUID as a string, because I use it in a SQL Server Database call...It yells at me if try to do a query with it in there.

Am I doing something wrong? or is there just no way to pass a GUID through the querystring?

ThanksIf you pass the value on the url it will be in a string format. The following worked for me. Maybe this will help.

select * from table1 where uniqueID = cast('{5BEEAA61-394B-44F6-9AC8-A6EA5FC99490}' as uniqueidentifier)
You need to do the following:

Dim MyGuid As Guid = New Guid(Request.QueryString("myGuid"))

0 comments:

Post a Comment