唯一标识符传递参数给存储过程 [英] Passing uniqueidentifier parameter to Stored Procedure

查看:130
本文介绍了唯一标识符传递参数给存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用下面的代码通过一个唯一标识符参数到存储过程:

I am trying to pass a uniqueidentifier parameter to a stored procedure using the following code:

myCommand.Parameters.Add("@BlogID", SqlDbType.UniqueIdentifier).Value = "96d5b379-7e1d-4dac-a6ba-1e50db561b04";



我不断收到然而一个错误说,该方案是无法从字符串转换成GUID。我是传递值不正确?

I keep getting an error however saying that the program was unable to convert from string to GUID. Am I passing the value incorrectly?

推荐答案

试试这个

myCommand.Parameters.Add("@BlogID", SqlDbType.UniqueIdentifier).Value = new Guid("96d5b379-7e1d-4dac-a6ba-1e50db561b04");

这篇关于唯一标识符传递参数给存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆