Converting Guids, and using parameterized stored procedures

D

dew

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, because sometimes it's not a guid, but in
this procedure it is.
How do I convert the GetClientID into a Guid? I tried

dim clientid as guid = CType(GetClientID("OrgName"), guid)

but I get an error that says it cannot convert a string into a guid. I even
tried manually inserting a known guid in place of the GetClientID function
and still get the same error.

I tried changing the function GetClientID to return an object, and I get the
same conversion error.

On the other hand, I cannot change ClientID to a string, because then my
stored procedure will not work. My parameter is :
param=cmd.parameters.add("@WorkerID", sqldbtype.uniqueidentifier, 255)

I cannot change the parameter because the stored procedure will not work, if
I change the stored procedure to be a uniqueidentifier, I get an error that
says Syntax .... converting string to a uniqueidentifier.

So what am I missing: I need to retrieve a uniqueidentifier (the client
id), so I can update other records using that clientid and I just don't seem
to have all the ducks in a row.

Thanks for your help.
 
A

Alex D.

this is how I do it in c#:

execProc.Parameters.Add("@id", SqlDbType.UniqueIdentifier).Value = new
Guid(myString);

Hope that helps;
Alex.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top