Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to know if a string is GUID?

Posted on 2013-02-03
6
Medium Priority
?
347 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 75

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 75

Accepted Solution

by:
käµfm³d   👽 earned 1000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

704 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