日期:2014-05-17 浏览次数:20440 次
string constring = ConfigurationManager.AppSettings["ConString"];
using (SqlConnection conn = new SqlConnection(constring))
{
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from t_tmp", conn);
DataSet ds = new DataSet("table");
da.Fill(ds, "table");
SqlDataAdapter da2 = new SqlDataAdapter("select * from t_citycode where citycode='11'", conn);
DataSet ds2 = new DataSet("table2");
da2.Fill(ds2,"table2");
ds.Tables[0].Merge(ds2.Tables[0], true);
SqlCommandBuilder cb = new SqlCommandBuilder(da);
da.InsertCommand = cb.GetInsertCommand();
Response.Write(cb.GetInsertCommand().CommandText);
da.Update(ds.Tables[0]);
ds.Tables[0].AcceptChanges();
gv.DataSource = ds;
gv.DataBind();
conn.Close();
}