转换失败 [英] conversion failed
问题描述
SqlCommand delcmd = new SqlCommand();
           delcmd.CommandText =" DELETE FROM add_investor WHERE investor_cnic =" + dataGridView1.SelectedRows [0] .Cells [0] .Value.ToString()
+"" ;;
                 my.Open();&
      delcmd.Connection = my;
      delcmd.ExecuteNonQuery();
      my.Close();
      dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows [0] .Index);
           my.Close();
SqlCommand delcmd = new SqlCommand();
delcmd.CommandText = "DELETE FROM add_investor WHERE investor_cnic=" + dataGridView1.SelectedRows[0].Cells[0].Value.ToString()
+ "";
my.Open();
delcmd.Connection = my;
delcmd.ExecuteNonQuery();
my.Close();
dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[0].Index);
my.Close();
将nvarchar值'34101-1212121-1'转换为数据类型int时转换失败。
Conversion failed when converting the nvarchar value '34101-1212121-1' to data type int.
什么是错的
推荐答案
显然,datagrid列的值是'34101-1212121-1',显然可以不能转换为整数(例如1或10)。
Apparently the value of the datagrid column is '34101-1212121-1', which obviously can't be converted to an integer (such as 1 or 10).
这篇关于转换失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!