Solved

How to know if a string is GUID?

Posted on 2013-02-03
6
324 Views
Last Modified: 2013-02-03
I have a sql statement that joins to 2 tables and brings back an ID row. I changed the design and the new IDs are integers. The old IDs are GUIDs.

How can I know if the ID is GUID and not an integer? based on that, i want to use an if-else statement.

thanks
0
Comment
Question by:Camillia
  • 2
  • 2
  • 2
6 Comments
 
LVL 9

Expert Comment

by:Aeriden
ID: 38849312
You can create a SQL Function that would return whether a GUID is valid:

http://ask.sqlservercentral.com/questions/23114/best-way-to-check-that-a-stringvarchar-guid-is-val.html
0
 
LVL 7

Author Comment

by:Camillia
ID: 38849324
want to do it in C#, ASP.net. But let me look at your link
0
 
LVL 9

Assisted Solution

by:Aeriden
Aeriden earned 250 total points
ID: 38849416
Oh, that is even easier.  Check out http://www.geekzilla.co.uk/View8AD536EF-BC0D-427F-9F15-3A1BC663848E.htm (using a Regular Expression for a GUID test).
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 38849450
Why not use Guid.Tryparse?
0
 
LVL 7

Author Comment

by:Camillia
ID: 38849475
so if (Guid.Tryparse(field) = true)

?
0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 38849542
No.

Guid converted;

if (Guid.TryParse("{81a130d2-502f-4cf1-a376-63edeb000e9f}", out converted) == true)
{
    // converted will hold the converted value if the TryParse succeeds
}

Open in new window

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now