473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Converting a Guid to a string

How do I convert a Guid to a string? I am trying to retrieve a value from a
dataview into a string variable:

CurrentValue = drv(strColumn)

and it works fine until the strColumn is a guid column, then I tried this:

Current Value = CType(drv(strColumn), String)

and I get an error that the cast is not valid.

Thanks very much for your help.

Nov 19 '05 #1
3 12774
On Tue, 10 May 2005 11:53:06 -0500, Eagle <ea*************@yahoo.com>
wrote:
How do I convert a Guid to a string? I am trying to retrieve a value
from a
dataview into a string variable:

CurrentValue = drv(strColumn)

and it works fine until the strColumn is a guid column, then I tried
this:

Current Value = CType(drv(strColumn), String)

and I get an error that the cast is not valid.

Thanks very much for your help.


There's not a direct cast possible there (even tho you know a GUID has a
string representation)...cast it to a Guid first, then do a ToString() on
it:

CType(drv(strColumn), Guid).ToString()

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #2
No need to cast it to a guid first. Just call ToString() on it.

Also, turning Option Strict On would catch these types of problems during
compile time, as opposed to run time.

"Craig Deelsnyder" <cdeelsny@no_spam_4_meyahoo.com> wrote in message
news:op***************@wtsp01tec520.nac.hscorp.com ...
On Tue, 10 May 2005 11:53:06 -0500, Eagle <ea*************@yahoo.com>
wrote:
How do I convert a Guid to a string? I am trying to retrieve a value
from a
dataview into a string variable:

CurrentValue = drv(strColumn)

and it works fine until the strColumn is a guid column, then I tried
this:

Current Value = CType(drv(strColumn), String)

and I get an error that the cast is not valid.

Thanks very much for your help.


There's not a direct cast possible there (even tho you know a GUID has a
string representation)...cast it to a Guid first, then do a ToString() on
it:

CType(drv(strColumn), Guid).ToString()

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Nov 19 '05 #3
Thanks everyone! It now works!
"Eagle" <ea*************@yahoo.com> wrote in message
news:uz**************@TK2MSFTNGP14.phx.gbl...
How do I convert a Guid to a string? I am trying to retrieve a value from a dataview into a string variable:

CurrentValue = drv(strColumn)

and it works fine until the strColumn is a guid column, then I tried this:

Current Value = CType(drv(strColumn), String)

and I get an error that the cast is not valid.

Thanks very much for your help.

Nov 19 '05 #4

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

Similar topics

1
by: Sandra | last post by:
I am trying to convert a string into a uniqueidentifier by using the following code string contrID = Request.Params["oId" SqlGuid sqlID = SqlGuid.Parse(contrID I am then putting sqlID into my...
1
by: vector | last post by:
I've got an application that generates GUIDs. A lot of GUIDs. Lots of GUIDs that end up in files on disk, taking up space. I'd like to continue using the Guid.NewGuid() function as my unique tag...
5
by: rcolby | last post by:
Evening, Wondering if someone can point me in the right direction, on how I would compare a system.guid with a system.byte. system.guid (pulled from sql server table with a data type of...
1
by: Scott M. Lyon | last post by:
I've got a stored procedure that takes a few parameters as input parameters, and one output parameter (a uniqueidentifier). After the stored procedure call, I need to return that output parameter...
3
by: dew | last post by:
I have a stored procedure that retrieves the id of a client table, which is a guid To get that id, I have dim clientid as guid = GetClientID("OrgName") The GetClientID returns a string,...
1
by: SealedClassSingleton | last post by:
Hi, When calling a stored procedure on a SQL 2005 DB with the managed SQL ADOprovider I got the following exception: Syntax error converting character string to uniqueidentifier when I use...
5
by: Michael Primeaux | last post by:
I have a simple .NET 2.0 web service created with VS.NET 2005 with a single web method with the following signature: void HelloWorld(Guid parameter1); When calling this method I receive the...
2
by: Jeff | last post by:
ASP.NET 2.0 I have a GridView on my webpage. As one of its columns I've put a HiddenField into a TemplateField. The porpose of this HiddenField is to hold the ID of the row. Each row in the...
4
by: Marc | last post by:
Hi, I don't get it I cannot get this to work, can somebody give me a hint Table1 contains a field Id which is a GUID as primary key and DATA a string, I want to insert a new row but it does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...

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.