GUID

G

Guest

How do I use Option Strict with a GUID: Here is the code sample. Convert
does not have a 128 integer type nor GUID type. So how do I make a GUID Type
Safe?

Public Function Load(ByVal iGUID As Guid) As Structures.Record Implements
Interfaces.Record.Load
Dim cn As New
SqlConnection(SQL.Connection.Info.SQLConnectionString)
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim sPerson As Structures.Record

cn.Open()

With cmd
.Connection = cn
.CommandType = CommandType.StoredProcedure
.CommandText = "usp_Person_Load"
.Parameters.Add("@id", iGUID)
End With

da.Fill(ds)

cmd = Nothing
cn.Close()

With ds.Tables(0).Rows(0)

sPerson.UniqueID = Convert. ? (.Item("UniqueID")) *here is
the problem

sPerson.FirstName = Convert.ToString(.Item("FirstName"))
sPerson.MiddleName = Convert.ToString(.Item("MiddleName"))
sPerson.LastName = Convert.ToString(.Item("LastName"))
End With

ds = Nothing

Return sPerson

End Function
 
N

Nick Malik [Microsoft]

what type is Structures.UniqueId?

You can convert a GUID to a string, or just store it as a GUID.
to convert to string, get it as a Guid and call ToString()
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemguidclasstostringtopic2.asp


--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top