473,326 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

GUID

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
2 1960
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Louis Frolio | last post by:
Greetings All, I have read many upon many articles here regarding GUID data types and uniqueness. There have been many opinions regarding the effectiveness of GUID's and when they should/should...
6
by: Jim Heavey | last post by:
When I use the new(Guid), the GUID which is generated is all zeros. Is there a technique for the system to assign a real Guid? Do I have to manually calculate a GUID?
9
by: Rene | last post by:
I am using the Guid.Empty value ("00000000-0000-0000-0000-000000000000") to represent a special meaning. The problem is that I don't know if there is a chance that a command like...
14
by: Nak | last post by:
Hi there, Does anyone know how I would get the value of the assembly GUID in code from within the same application? Thanks in advance. Nick. --...
5
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...
5
by: George | last post by:
I want to create a unique id for each of a set of objects. These ids may be generated on multiple machines simultaneously and must all be different to each other. There are an undefined number...
1
by: Wolf | last post by:
Hi I am trying to set a property(PartyHomeAddressID) = to a guid in a ini file. But everytime when the ini file has an empty guid it breaks with an error tellin me a guid is 32 char long with 4...
5
by: Michael Primeaux | last post by:
I have a simple .NET 2.0 web service created with VS.NET 2005 with a single web method with the following signature: void HelloWorld(Guid parameter1); When calling this method I receive the...
2
by: Troll | last post by:
Windows XP Pro VS 2005 & C# (I'm fairly new to C# but have doing VB.Net going on 2yrs and VB6 for 5yrs.) I'm using C# to build a custom RSS generator. I'm having trouble building the guid...
4
by: Marc | last post by:
Hi, I don't get it I cannot get this to work, can somebody give me a hint Table1 contains a field Id which is a GUID as primary key and DATA a string, I want to insert a new row but it does not...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.