//
// DataTable dt = null;
// DataRow dr = null;
// dt = new DataTable();
// dt.Columns.Add("1", System.Type.GetType("System.String"));
// dt.Columns.Add("2", System.Type.GetType("System.String"));
// dt.Columns.Add("3", System.Type.GetType("System.String"));
// dt.Columns.Add("4", System.Type.GetType("System.String"));
// dt.Columns.Add("5", System.Type.GetType("System.String"));
// dt.Columns.Add("6", System.Type.GetType("System.String"));
// dt.Columns.Add("7", System.Type.GetType("System.String"));
// foreach (ListViewItem lvi in lvinfo.Items)
// {
// dr = dt.NewRow();
// string tmz=lvi.SubItems[0].Text;
// string khid=lvi.SubItems[1].Text;
// string hd = lvi.SubItems[2].Text;
// string cd = lvi.SubItems[3].Text;
// string mz = lvi.SubItems[4].Text;
// string jz = lvi.SubItems[5].Text;
// string ys = lvi.SubItems[6].Text;
// dr[0] = khid;
// dr[1] = hd;
// dr[2] = cd;
// dr[3] = mz;
// dr[4] = jz;
// dr[5] = ys;
// dr[6] = tmz;
// dt.Rows.Add(dr);
// }
//
// string con = "server=(local);uid=sa;pwd=sa;database=jxcdata";
//
// System.Data.SqlClient.SqlBulkCopy sqlbulk = new System.Data.SqlClient.SqlBulkCopy(con, SqlBulkCopyOptions.UseInternalTransaction);
// sqlbulk.NotifyAfter = dt.Rows.Count;
// //目标数据库表名
// sqlbulk.DestinationTableName = "proinfo";
产品信息表 proinfo
ID proid
客户代号(半成品编号) procode
厚度 prothink
颜色 procolor
毛重 promwei
净重 projwei
长度 prolength
条码 (唯一)(半成品编号)probar
// //数据集字段索引与数据库字段索引映射
// sqlbulk.ColumnMappings.Add(0, "procode");
// sqlbulk.ColumnMappings.Add(1, "prothink");
// sqlbulk.ColumnMappings.Add(5, "procolor");
// sqlbulk.ColumnMappings.Add(3, "promwei");
// sqlbulk.ColumnMappings.Add(4, "projwei");
// sqlbulk.ColumnMappings.Add(2, "prolength");
// sqlbulk.ColumnMappings.Add(6, "probar");
// //导入
// sqlbulk.WriteToServer(dt);
// sqlbulk.Close();
// MessageBox.Show("ok");