Is there any built-in method in asp.net to convert a string to a uniqueidentifier
for SQL Server, just like .ToString()
.
我有了一个错误: 转换在从特性上传给独一无二的识别器时失败。
或者任何人都知道如何解决这一问题。 感谢。
Is there any built-in method in asp.net to convert a string to a uniqueidentifier
for SQL Server, just like .ToString()
.
我有了一个错误: 转换在从特性上传给独一无二的识别器时失败。
或者任何人都知道如何解决这一问题。 感谢。
<代码>准则代码>的构造者,以<代码>载为参数。
Guid aGuid = new Guid(aString);
2. 正确确保:
A string that contains a GUID in one of the following formats ("d" represents a hexadecimal digit whose case is ignored):
32个毗连数字:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
- 或
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 - 或{dddddddd-dddd-dddd-dddd-dddddddddddd} - 或(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}}
全文见。
你可以把你的作用作为参数:
Guid roleID = new Guid(roleIDAsString);
sqlCommand.Parameters.Add("@RoleID", SqlDbType.UniqueIdentifier).Value = roleID;
Guid outGuid;
Guid.TryParse(stringInput, out outGuid);
Won t crash if the string is incorrectly formatted
你们可以使用
Guid myNew = new Guid("xxxx-xxx");
string aspUserID = myObject.ProviderUserKey.ToString();
Guid userGuid = new Guid(aspUserID);
或
Guid yourGuid = new Guid(yourString);
在使用前的舱面值检查
Guid g = new Guid(string) ;
In my webpages I have references to js and images as such: "../../Content/Images/"Filename" In my code if I reference a file as above, it doesnt work so i have to write: "c:/miscfiles/"filename" 1-...
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
I m looking for best practices here. Sorry. I know it s subjective, but there are a lot of smart people here, so there ought to be some "very good" ways of doing this. I have a custom object called ...
I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...
i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...
For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?
I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!