var num = new[] {1, 2, 8, 9}
// .net 4或以上
// var sql = string.Format("select id, a, b from A where id in ( {0} )", string.Join(", ", num))
// .net 4以下
var numStr = Array.ConvertAll(num, input => input.ToString())
var sql = string.Format("select id, a, b from A where id in ( {0} )", string.Join(", ", numStr))
var dataTable = new DataTable()
using (var dataAdapter = new SqlDataAdapter(sql, connectoin))
{
dataAdapter.Update(dataTable)
}
改下单引号的位置。string commString = "insert into goods(idgoods,namegoods,price,nub,category) values(" + textBox1.Text + ",'" + textBox2.Text + "'," + textBox3.Text + ",'" + textBox4.Text + "'," + this.comboBox1.Text + "')"
再有错就是你没把字符串列全用单引号括起来。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)