473,382 Members | 1,409 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,382 software developers and data experts.

How to convert a string to a GUID

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 dashes.
client.PartyHomeAddressID = new Guid(contact.Substring(1542,
36).Trim());

If its not Empty GUID, it doesnt break.

Is the reason maybe because I am specifying new Guid( around a empty
guid?
If this is the case, how do I convert it to read a GUID

Thanks a million in advance

Jan 26 '06 #1
1 4079
Wolf wrote:
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 dashes.

client.PartyHomeAddressID = new Guid(contact.Substring(1542,
36).Trim());

If its not Empty GUID, it doesnt break.

Is the reason maybe because I am specifying new Guid( around a empty
guid?
If this is the case, how do I convert it to read a GUID


The constructor Guid(string) assumes that you're passing it a valid
string representation of a Guid. If you're not, it's (not unreasonably)
complaining.

What do you *want* it to do if your ini file has an empty guid? Should
it create a new Guid, should it use an "all zero" Guid? Your code needs
to decide this - check whether or not a guid has been supplied in the
ini file, use it if it has, and take appropriate action if not.

Jon

Jan 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: James DeClerk | last post by:
Hi everyone. I have a guid that's in string format. I would like to convert it to a GUID. I'm doing this on the unix platform, so it will apply to only to GCC/G++. #include "stdafx.h"...
1
by: Jeffrey B. Holtz | last post by:
I'm trying to get the Name of the USB device pluged in from the RegisterDeviceNotification that I've used P/Invoke to marshal. I have seen a similar posting on the VisualBasic newgroups but I do...
2
by: jiangyh | last post by:
hi there : I have a question about how to convert Type to DbType? thanks a lot. jiangyh
7
by: Charles Law | last post by:
Can anyone convert the following C++ interface definition to VB.NET? I have had a go, but I cannot make the Load function work and the IsDirty function gives an error (Object not set to an...
1
by: guoqi zheng | last post by:
I have a string, e.g. DC238D6668E341529BBA0F960C661399 which was a guid before. I need to convert this back to a datatype Guid. How can I do this??? regards, Guoqi Zheng...
6
by: Sandy | last post by:
I'm building a SQL String and I want to choose only the records that are part of the current contractID. My Variable Dim contrID = Request.Params("oId" I put it into the SQL String WHERE ...
2
by: jmhmaine | last post by:
I have the the folllowing code that works when Option Strict is Off: Dim SearchID as string = "2F0B92F1-23E5-4CFA-B8D6-FAFEADE90EBC" Dim SearchGUID As Guid SearchGUID =...
0
by: MarcoDieleman | last post by:
Hello you all, I have this code that is written in MS Transact-SQL and I need to convert it to work with Oracle. Can anyone please help??? I need the code for a VBscript project. Thanks! ...
9
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, i am a little stuck here, how do i convert this from C Structure to an structure in C# that can be marshalled: typedef struct _DEV_BROADCAST_DEVICEINTERFACE { DWORD dbcc_size; DWORD...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.