By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,151 Members | 1,061 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,151 IT Pros & Developers. It's quick & easy.

GUID

P: n/a
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.SQLConnectionStr ing)
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

Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Would this work?

sPerson.UniqueID = CType(.Item("UniqueID"), Guid)

http://tinyurl.com/4joqw

Greg

"Ereck" <Er***@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
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.SQLConnectionStr ing)
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

Jul 21 '05 #2

P: n/a
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...ringtopic2.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.
--
"Ereck" <Er***@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
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.SQLConnectionStr ing)
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

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.