Solved

Convert GUID to String value

Posted on 2009-03-30
2
4,633 Views
Last Modified: 2013-11-26
I am trying to delete a record from a SQL server table using a GUID.   The WHERE clause in my sql statement uses a field in the table that is defined as a uniqueidentifier and the GUID that i am passing is a string value.

I am get the error "Conversion failed when converting from a character string to uniqueidentifier".   How can i convert the string GUID value so that i can delete this record.   I am using vb.net and SQL Server 2008
0
Comment
Question by:Mike_Stevens
  • 2
2 Comments
 
LVL 9

Expert Comment

by:cdaly33
Comment Utility
If you just need the code in sql you should try:
where columnname = cast("guidyouwanttodelete" as uniqueidentifier)

Open in new window

0
 
LVL 9

Accepted Solution

by:
cdaly33 earned 500 total points
Comment Utility
If the issue is in vb you can create a guid object with a specific id like this:
Dim guidtodelete As Guid = New Guid("guidyouwanttodelete")

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

7 Experts available now in Live!

Get 1:1 Help Now