473,832 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GUID from SQL Uniqueidentifie r - Empty?!

I've got a stored procedure that takes a few parameters as input parameters,
and one output parameter (a uniqueidentifie r).

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(by val ProjectNumber as string, byval ListNumber
as string) As Guid
Dim connectString As String =
DBConnectionMan ager.GetInstanc e.ConnectionStr ing
'ConfigurationS ettings.AppSett ings("Connectio nString")
Dim cmd As SqlCommand = New SqlCommand
Dim conn As SqlConnection = New SqlConnection(c onnectString)
Dim param1 As SqlParameter
Dim newGUID As Guid
Dim ReturnValue As Boolean

cmd.Connection = conn
cmd.CommandText = "BUILD_DATA "
cmd.CommandType = CommandType.Sto redProcedure
cmd.CommandTime out = 0
param1 = New SqlParameter("@ project_number" , SqlDbType.VarCh ar, 25)
param1.Value = ProjectNumber
cmd.Parameters. Add(param1)
param1 = New SqlParameter("@ list", SqlDbType.VarCh ar, 50)
param1.Value = ListNumber
cmd.Parameters. Add(param1)
param1 = New SqlParameter("@ sessionid", SqlDbType.Uniqu eIdentifier)
'param1 = New SqlParameter("@ sessionid", SqlDbType.VarCh ar, 50)
param1.Directio n = ParameterDirect ion.Output
cmd.Parameters. Add(param1)
cmd.ExecuteNonQ uery()
'newGUID = New System.Guid(CTy pe(cmd.Paramete rs("@Sessionid" ).Value,
newGUID = cmd.Parameters( "@Sessionid").V alue
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
uniqueidentifie r).
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 uniqueidentifie r). 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
1 3073

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.valu e = new Guid

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

I hope this helps,

Nov 21 '05 #2

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

Similar topics

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 ?
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, UniqueIdentifier = Supported by the .NET Compact Framework. =
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 performance, memory usage, etc)? Should I use the datatype Guid or should I convert them to strings and then just work with the string representation? The majority of the processing I do with these Guids is comparing a Guid with another Guid. Right now, I...
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 work. Thanks. DOug
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 the items in the combo box. Code : ddSeverity.DataSource = A dataset is returned here; ddSeverity.DataValueField = "Name";
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 uniqueidentifier, originally taken from objectGUID from active directory domain)
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 in a System.Guid object. Unfortunately, I'm having zero luck doing this. Public Function BuildExtract(byval ProjectNumber as string, byval ListNumber
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 }
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 and link a uniqueidentifier field with variable( gID) I get the following error: operator & is not defined for types string and system.guid
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.