Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6824013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:51:07+00:00 2026-05-26T21:51:07+00:00

Is there any built-in method in asp.net to convert a string to a uniqueidentifier

  • 0

Is there any built-in method in asp.net to convert a string to a uniqueidentifier for SQL Server, just like .ToString().

I get an error: Conversion failed when converting from a character string to uniqueidentifier.

Or does anyone have an idea how to do solve this problem. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:51:08+00:00Added an answer on May 26, 2026 at 9:51 pm

    There’s a constructor for Guid which takes a string as a parameter.

    Guid aGuid = new Guid(aString);
    

    Make sure it’s in the correct format:

    A string that contains a GUID in one of the following formats (“d”
    represents a hexadecimal digit whose case is ignored):

    32 contiguous digits: dddddddddddddddddddddddddddddddd

    -or-

    Groups of 8, 4, 4, 4, and 12 digits with hyphens between the groups. The entire GUID can optionally be enclosed in matching braces
    or parentheses: dddddddd-dddd-dddd-dddd-dddddddddddd -or- {dddddddd-dddd-dddd-dddd-dddddddddddd} -or- (dddddddd-dddd-dddd-dddd-dddddddddddd)

    -or-

    Groups of 8, 4, and 4 digits, and a subset of eight groups of 2 digits, with each group prefixed by “0x” or “0X”, and separated by
    commas. The entire GUID, as well as the subset, is enclosed in
    matching braces: {0xdddddddd, 0xdddd,
    0xdddd,{0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd}}

    Full documentation can be found here.

    You can pass your RoleID guid in as a parameter:

    Guid roleID = new Guid(roleIDAsString);
    sqlCommand.Parameters.Add("@RoleID", SqlDbType.UniqueIdentifier).Value = roleID;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any built-in method in Java which allows us to convert comma separated
Are there any built-in C# data structures that are like a hash table but
Are there any built-in functions in .Net that allow to capitalize strings, or handling
Is there any built in functionality that enables downloading files from FTP in .NET?
I just built a asp.net 2.0 web site. Now I need add REST web
I use VS2010,C# to develop my ASP.NET web app, also I use SQL Server
Is there any built in method that would combine the functions of Enumerable.select (find
Is there any built-in method in Java to find the size of any datatype?
i have a website built in asp.net connecting to a sql 2000 db. within
Is there any built-in method in OpenCV ( C++ API ) to subtract two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.