sda.Update批量更新数据

老方法了,重新做个记录。

string connStr = ConfigurationManager.ConnectionStrings["constring"].ToString();
SqlDataAdapter sda = null;
DataTable dt = Common.ListToDataTable<CityInfoWAP>(lst.OrderBy(o => o.firstLetter).ToList<CityInfoWAP>());
using (SqlConnection conn = new SqlConnection(connStr))
{
	conn.Open();
	string sql = "SELECT firstLetter,code,spell,spellShort,name FROM EnterpriseCitysFlightWAP";
	sda = new SqlDataAdapter(sql, conn);
	SqlCommandBuilder sqlcb = new SqlCommandBuilder(sda);
	sda.Update(dt);
	WebHelper.LogHelper.WriteLog("数据插入成功!");
}

 另见:http://skybirdzw.blog.163.com/blog/static/7257062620111151075017/

posted @ 2018-01-10 17:40  skybirdzw  阅读(256)  评论(0编辑  收藏  举报