?
Solved

Convert GUID to String value

Posted on 2009-03-30
2
Medium Priority
?
4,650 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
[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 Comments
 
LVL 9

Expert Comment

by:cdaly33
ID: 24022804
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 2000 total points
ID: 24022816
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

771 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