472,978 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,978 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 12756
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.