项目放在服务器上,访问者发表内容提示将截断字符串或二进制数据,查找了相应的字段类型,字段类型都尝试了设置最大还是出错,现在设置的是varchar(max),这个项目本机运行正常,调试也正常,现在很懊恼不知道该怎么办。将截断字符串或二进制数据

解决方案 »

  1.   

        protected void imgPost_Click(object sender, ImageClickEventArgs e)
        {
            Models.Article article = new Models.Article();
            article.ATitle = this.txtTitle.Text.ToString();
            article.AContent = txtContent.Value;
            article.ATime = DateTime.Now;
            article.AIPAddress = Request.UserHostAddress;
            article.AImage = "";
            article.AClicks = 0;
            article.ARatify = 1;
            article.AType = this.ddlType.SelectedIndex;
            article.ASign = this.ddlSign.SelectedIndex;
            article.Author = user;        if (ArticleManager.AddArticle(article) != null)
            {
                Response.Redirect("~/refresh.aspx?msg=" + "恭喜你,发表成功!文章正在审核,请稍等。");
            }
            else
            {
                this.lblMsg.Text = "很遗憾,发表失败,请重新尝试!";
            }
        }  获取本地时间啊
      

  2.   

    还是会报错。
    请把你的查询语句 贴出来 这个返回的是第一列第一行的数据 是int行的么 或者能不能转换成int 
      

  3.   


    请把你的查询语句 贴出来 这个返回的是第一列第一行的数据 是int行的么 或者能不能转换成int 不明白,这是是进行添加功能的。
      

  4.   

    可能user没取到值吧? article.Author = user;
      

  5.   


    不明白,这是是进行添加功能的。
    添加用executeScalar 干嘛 这是查询用的 返回第一行第一列的值
      

  6.   


    不明白,这是是进行添加功能的。
    添加用executeScalar 干嘛 这是查询用的 返回第一行第一列的值
    照你这么说我放服务器上就要出错, 为嘛本机运行正常。
      

  7.   

    这个可以取到值。
    你查询的方法换一下这个可以取到值。
    换一个executeScalar 换为ExecuteNonQuery
      

  8.   

    这个是因为 你其中某个字段 值长度 超过了 你所设置字段的长度。  比如 name char(10)  实际输入的时候 name 超过 10 了。
      

  9.   

    你的 地址 AIPAddress 才分配 varchar(10) 字符 只能输入 5个汉字  在看看你输入 的是多少个字
      

  10.   


     这个字段长度,我设置最大了 ,本机环境运行正常。算了 还是把sql语句贴出来吧 
      

  11.   


     这个字段长度,我设置最大了 ,本机环境运行正常。算了 还是把sql语句贴出来吧 
            public static Article AddArticle(Article article)
            {
                string sql =
                    "INSERT Articles (AuthorId, aTitle, aContent, aTime,aIPAddress,aImage,aClicks,aRatify,aType,aSign)" +
                    "VALUES (@AuthorId, @aTitle, @aContent,@aTime,@aIPAddress,@aImage,@aClicks,@aRatify,@aType,@aSign)";
                sql += " ; SELECT @@IDENTITY";            SqlParameter[] para = new SqlParameter[]
    {
    new SqlParameter("@AuthorId", article.Author.Id), //FK
    new SqlParameter("@aTitle", article.ATitle),
    new SqlParameter("@aContent", article.AContent),
                        new SqlParameter("@aTime",article.ATime),
                        new SqlParameter("@aIPAddress",article.AIPAddress),
                        new SqlParameter("@aImage",article.AImage),
    new SqlParameter("@aClicks", article.AClicks),
    new SqlParameter("@aRatify", article.ARatify),
                        new SqlParameter("@aType",article.AType),
                        new SqlParameter("@aSign",article.ASign)
    };            int newId = DBHelper.GetScalar(sql, para);
                return GetArticleById(newId);
            }
      

  12.   

    还是会报错。那个aImage的类型怎么会是这个呢?不是Image类型的
      

  13.   

    你把同样的数据,用sql直接插入试试,看sqlserver怎么提示,首先确定一下,到底是哪个字段超了。
      

  14.   

    这个字段我设置的是自动获取本机IP地址,这个不会自己超出先有字段吧。
    四位ip 3*4=12 再加上点"."
    你说超不