SqlConnection con = new SqlConnection(str);
StringBuilder strSQL = new StringBuilder();
strSQL.Append("insert into [I-STOCK] values('" + label2.Text + "','" + listView1.Items[0].SubItems[0].Text + "','" + label4.Text + "','" + label6.Text + "')");
foreach (ListViewItem item in listView1.Items)
{
strSQL.Append("insert into [I-STOCKA] values ('"+item+"')");
}
using( SqlCommand cmd = new SqlCommand(strSQL.ToString(),con))
{
con.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("OK");
con.Close();
}
这是我写的一个把listview中数据存储到数据库中的语句
老报错,说插入错误