删除抛出异常的 SQLCommand

Deleting SQLCommand throwing inadequate exception

我有虚拟 dataGridView,它通过即时方法 documentation here 显示 table 中的所有值。我的视图有更多的计算列,所以我只用它来显示数据,然后只用单个 SQLCommand 删除。 当我执行删除命令时出现问题。当我执行它时,它会抛出错误

Conversion failed when converting the nvarchar value 'TextValueFromThirdColumn' to data type int.

xxx不是ID,是第三列的计算数据

using(SqlConnection c = new SqlConnection(Properties.Settings.Default.ConnectionString))
     {
          c.Open();
          SqlCommand command = new SqlCommand("delete from entryTable where ID = @id", c);
          command.Parameters.AddWithValue("@id", dataGridView1.SelectedRows[0].Cells["ID"].Value.ToString());
          command.ExecuteNonQuery();
     }

如您所见,我正在使用添加的参数构建查询,但抛出的错误对我来说似乎不足,因为第三列与我的 ID 列无关。在此先感谢您的任何建议

好吧,这是我的愚蠢错误。这是 SQL 服务器上的触发器问题。我没有意识到我更改了数据库布局并且触发器停止工作,因为它将值插入了错误的列。错误代码显示触发器发生了什么,而不是行发生了什么。