无法将参数值从字符串转换为guid [英] failed to convert parameter value from string to guid

查看:922
本文介绍了无法将参数值从字符串转换为guid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用过asp c#

i used asp c#

SqlParameter[] paramdizi2 = new SqlParameter[3]
            {                
                new SqlParameter("@UserId",SqlDbType.UniqueIdentifier),  
                new SqlParameter("@RolId",SqlDbType.UniqueIdentifier),
                new SqlParameter("@Sonuc",SqlDbType.Int) 
                                  
            };
            paramdizi2[0].Value = TxtUserId.Text;
            paramdizi2[1].Value = TxtRolId.Text;
            paramdizi2[2].Direction = ParameterDirection.ReturnValue;
            baglan.ExecuteNonQuery("RolDuzenle", CommandType.StoredProcedure, paramdizi2);



无法将参数值从字符串转换为guid.

我该怎么做?



Failed to convert parameter value from string to guid.

How can I do this?

推荐答案

您正试图将字符串值插入数据库的GUID字段.
检查您的代码,然后在UniqueIdentifier字段中插入有效的GUID.

检查@userid和@roleid是否都属于uniqueidentifier ...

您可以通过尝试上述几点来捕获错误:)
you are trying to insert string value to a GUID field of your database.

Check your code and insert a valid GUID into the UniqueIdentifier field.

check if @userid and @roleid both are of type uniqueidentifier...

you may catch error by trying above points :)


尝试在分配之前将字符串转换为GUID:
Try to convert string to GUID before assigning:
paramdizi2[0].Value = New Guid(TxtUserId.Text);


这篇关于无法将参数值从字符串转换为guid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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