//执行DataTable数据导入 public static int UpdateDt(string strConn, DataTable dt) { try { string tablaName = dt.TableName; string strSQL = string.Format(" Select * From {0} Where 1=2 ", tablaName); int obj = 0; using (SqlConnection con = GetConnection(strConn)) { using (SqlDataAdapter adp = new SqlDataAdapter(strSQL, con)) { using (SqlCommandBuilder cmd = new SqlCommandBuilder(adp)) { if (con.State != ConnectionState.Open) con.Open(); obj = adp.Update(dt.GetChanges()); dt.AcceptChanges(); if (con.State != ConnectionState.Closed) con.Close(); } } } return obj; } catch (Exception ex) { return -1; } }