请修复“字符串或二进制数据将被截断。\ r \ n语句已被终止”

时间:2016-04-24 06:09:34

标签: c# sql-server ado.net

我想找到旧的坐标,并使用C#WPF在我的数据库中用新的坐标替换它。我收到了这个错误

  

字符串或二进制数据将被截断。\ r \ n语句已被删除   终止

我无法找到问题所在。这是我使用的方法:

 public void updateEvent(string oldCord,string newCord, DateTime dropDate)
    {

        using (SqlCommand cmd = new SqlCommand())
        {
            cmd.CommandText = "UPDATE Event SET Date = @newDate ,Cordinate=@newCord  WHERE  Cordinate = @oldCord";
            cmd.Parameters.AddWithValue("@newDate", dropDate);
            cmd.Parameters.AddWithValue("@newCord", newCord);
            cmd.Parameters.AddWithValue("@oldCord", oldCord);             
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.Connection = connection;
            cmd.ExecuteNonQuery();
        }
    }

1 个答案:

答案 0 :(得分:1)

通常,此问题的原因是您发送到存储过程的参数的长度大于数据库中实际表中字段的大小。