请修复"String or binary data would be truncated.rnThe statement has been terminated"



我想找到旧的坐标,并使用 C# WPF 在我的数据库中将其替换为新坐标。我收到此错误

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

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

 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();
        }
    }

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

最新更新