class Program { static void Main(string[] args) { string sourcedb = @"D:\code\Client\TestApplication\ConsoleApplication1\ConsoleApplication1\DB\Source.mdb"; string targetdb = @"D:\code\Client\TestApplication\ConsoleApplication1\ConsoleApplication1\DB\target.mdb"; string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+sourcedb+";Jet OLEDB:Database Password=qwer2009"; CopyDatatable(connstr, targetdb); } static void CopyDatatable(string connStr,string targetdb) { System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connStr); conn.Open(); //在没有生成目标表结构的时候,用select * into from,将自动生成源表结构 //string sql = string.Format("select * into [;database={0}].Ciq_C_Imex_Test_Mode from Ciq_C_Imex_Test_Mode t where t.x_code='1'", targetdb); //在已经存在目标表时,用insert into select * from string sql = string.Format("insert into [;database={0}].Ciq_C_Imex_Test_Mode select * from Ciq_C_Imex_Test_Mode t where t.x_code='3'",targetdb); System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(sql,conn); cmd.ExecuteNonQuery(); conn.Close(); } }