日期:2014-05-17 浏览次数:20568 次
using (SqlConnection conn = new SqlConnection("server=.;uid=sa;pwd=123456;database=test;"))
{
SqlDataAdapter sda = new SqlDataAdapter("select * from t1", conn);
DataTable dt = new DataTable();
sda.Fill(dt);
using (OleDbConnection oleConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "se.mdb;"))
{
oleConn.Open();
foreach (DataRow dr in dt.Rows)
{
string sql = "insert into t2 values('" + dr[0] + "')";
OleDbCommand cmd = new OleDbCommand(sql, oleConn);
cmd.ExecuteNonQuery();
}
}
}