473,289 Members | 1,961 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,289 software developers and data experts.

GUID from SQL Uniqueidentifier - Empty?!

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 =
DBConnectionManager.GetInstance.ConnectionString
'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

conn.Open()
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
cmd.Parameters.Add(param1)
param1 = New SqlParameter("@list", SqlDbType.VarChar, 50)
param1.Value = ListNumber
cmd.Parameters.Add(param1)
param1 = New SqlParameter("@sessionid", SqlDbType.UniqueIdentifier)
'param1 = New SqlParameter("@sessionid", SqlDbType.VarChar, 50)
param1.Direction = ParameterDirection.Output
cmd.Parameters.Add(param1)
cmd.ExecuteNonQuery()
'newGUID = New System.Guid(CType(cmd.Parameters("@Sessionid").Val ue,
String))
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
uniqueidentifier).
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?
Thanks!
-Scott

Nov 21 '05 #1
1 3024
Scott,

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,

Cor
Nov 21 '05 #2

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

Similar topics

24
by: Ilija_G | last post by:
Hi, Is there any replace for "Select @@identity" that could return "just inserted" GUID as a primary key? Has anyone tested what's faster, working with Guid or Autonumber ?
2
by: Carl | last post by:
Hi, I do have one dataset from SQL server with a field (bound) to Textbox called txtID , this field is of type uniqueidentifier. From the doc, they say the equivalent is GUID in dot net, ...
3
by: Jeffry van de Vuurst | last post by:
Hi, I'm working with Guids as the primary key of some of my tables. In my code, I'm working with those Guids. Now I was wondering what is the best way to work with Guids (in terms of...
6
by: Doug | last post by:
I have a value that was a GUID converted to string and stored in the DB. I need to get that value back into a Guid, how can i do that? Do something like (System.Guid)<GUIDStringVariable> does not...
3
by: Gopal Krish | last post by:
I need to display uniqueidentifier (GUID) from a table in SQL Server into a ASP.NET Web Page (Combo box). I'm using C#. When I tried to display GUIDs in a combo box I get "System.Byte" for all...
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...
6
by: AlveenX | last post by:
Hi, I am trying to pick a Guid from a data row using the following code: foreach(DataRow row in MyDataTable.Rows) { (Guid)row }
8
by: =?Utf-8?B?QW5kcmV3?= | last post by:
Vb.net 2005 app I am looking up records in a sql 2005 database and I grab the uniqueidentifier and put it into a variable (gID) of type GUID. When I try to create a new record in a new table...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.