473,385 Members | 1,927 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,385 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 3033
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...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.