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
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