附加信息:将nvarchar值'Pending'转换为数据类型int时转换失败。 [英] Additional information: Conversion failed when converting the nvarchar value 'Pending' to data type int.

查看:114
本文介绍了附加信息:将nvarchar值'Pending'转换为数据类型int时转换失败。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public List<ads> GetAllPromotedAdverts()
        {

            List<ads%gt; AllFundrasing = new List<ads>();
            using (SqlConnection dbconn = new SqlConnection(ConnectionString))
            {
                SqlCommand dbCommand = new SqlCommand("GetAllPromotionAdverts", dbconn);
                dbCommand.CommandType = CommandType.StoredProcedure;
                dbconn.Open();

                SqlDataReader dbReader = dbCommand.ExecuteReader();


                while (dbReader.Read())
                {

推荐答案

我同意hypermellow:检查GetAllPromotionAdverts。当您尝试将文本附加到int时,通常会导致此错误:



I agree with hypermellow: check GetAllPromotionAdverts. This error is usually caused when you try to append text to an int like so:

select "id="+id from mytable



您必须将int转换为nvarchar,如下所示:


You have to cast the int to an nvarchar like so:

select "id="+cast(id as nvarchar(max)) from mytable





希望有所帮助^ _ ^

Andy



Hope that helps ^_^
Andy


这篇关于附加信息:将nvarchar值'Pending'转换为数据类型int时转换失败。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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