赞
踩
想将新的数据导入覆盖掉原来的数据,从第一行开始,所有列的数据都是新的,怎么写sql语句?求指点代码如下for(intb=0;b
想将新的数据导入覆盖掉原来的数据,从第一行开始,所有列的数据都是新的,怎么写sql语句?求指点
代码如下
for (int b = 0; b < dt.Rows.Count; b++)
{
string value1;
value1 = bp1[b, 0];
string insert = "INSERT INTO a(id) values('" + value1 + "') SELECT * FROM a where id = '" + id + "'";
SqlConnection conn = new SqlConnection(cs);
conn.Open();
SqlDataAdapter adapter = new SqlDataAdapter(insert, conn);
DataSet ds = new DataSet();
adapter.Fill(ds, "a");
SqlCommand cmd = new SqlCommand("select * from a", conn);
cmd.CommandType = CommandType.Text;
adapter.SelectCommand = cmd;
DataSet ds1 = new DataSet();
adapter.Fill(ds1, "a");
this.dataGridView1.DataSource = ds1;
this.dataGridView1.DataMember = "a";
conn.Close();
}
展开
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。