Thursday, March 01, 2007

Returning GUID from STP

Calling a store procedure to return a GUID:

PROCEDURE lookupGetEquipmentGUIDFromDomainName
@piDomainName nvarchar(50)
AS
BEGIN
SET NOCOUNT ON;

SELECT UPPER(EquipmentGUID) as EquipmentGUID
FROM Equipment
WHERE DomainName = @piDomainName
END


on the ADO.NET, make sure to get the .ToString of the object before converting it to a GUID type.

try
{
oConn.Open();
string s =
oCMD.ExecuteScalar().ToString();
outEquipment.EquipmentGuid = new Guid(s);
}


This will assign the GUID coming back to a type GUID in the object.

No comments: