By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

GUID from SQL Uniqueidentifier - Empty?!

P: n/a
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 in a
System.Guid object.
Unfortunately, I'm having zero luck doing this.

Public Function BuildExtract(byval ProjectNumber as string, byval ListNumber
as string) As Guid
Dim connectString As String =
'ConfigurationSettings.AppSettings("ConnectionStri ng")
Dim cmd As SqlCommand = New SqlCommand
Dim conn As SqlConnection = New SqlConnection(connectString)
Dim param1 As SqlParameter
Dim newGUID As Guid
Dim ReturnValue As Boolean

cmd.Connection = conn
cmd.CommandText = "BUILD_DATA"
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandTimeout = 0
param1 = New SqlParameter("@project_number", SqlDbType.VarChar, 25)
param1.Value = ProjectNumber
param1 = New SqlParameter("@list", SqlDbType.VarChar, 50)
param1.Value = ListNumber
param1 = New SqlParameter("@sessionid", SqlDbType.UniqueIdentifier)
'param1 = New SqlParameter("@sessionid", SqlDbType.VarChar, 50)
param1.Direction = ParameterDirection.Output
'newGUID = New System.Guid(CType(cmd.Parameters("@Sessionid").Val ue,
newGUID = cmd.Parameters("@Sessionid").Value
Return newGUID
End function

But when I do this, every time the GUID that is returned is empty (despite
confirming that the stored procedure is working properly and returning a
So I tried (as you can see from the commented out lines above) returning it
as a string instead (the sp still has it as a uniqueidentifier). When I did
that, I confirmed that the GUID is coming back properly, but when I tried to
create a new System.Guid using that value, once again I got an empty GUID.

What am I doing wrong?

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a

Please don't sent sample code with still old code ouddocumented code in it

I see a lot of lines however I have the idea that I miss.

Parameter1.value = new Guid

(I have the idea that I see much to much code)

I hope this helps,

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.