前提:datatable里有值,数据库中有相应的表
一、list,string方法
List<string> lstSql = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
{
string ticketNo = dt.Rows[i]["票号"].ToString();
string actualcollect = dt.Rows[i]["实收款"].ToString().Replace("-", "");
string issueDate = Convert.ToDateTime(dt.Rows[i]["出票日期"].ToString()).ToString("yyyy-MM-dd").Replace("-", "");
string refundCharge = dt.Rows[i]["退票手续费(航空公司)"].ToString();
string approvalStatus = dt.Rows[i]["审核状态"].ToString();
sql = "insert into CMB_Refund_TktNo_Ref(OnlineRecordTicketNo,Actualcollect,IssueDate,ApprovalStatus,RefundCharge)"
+ " values('{0}','{1}','{2}','{3}','{4}') ";
sql = string.Format(sql, ticketNo, actualcollect, issueDate, approvalStatus, refundCharge);
lstSql.Add(sql);
}
Hippo.ExecuteSqlTran(cmd);
lstSql.Clear();
执行方法
public static int ExecuteSqlTran(List<String> SQLStringList)
{
using (SqlConnection conn = new SqlConnection(connectionS