using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{

SqlConnection conn =new SqlConnection();
conn.ConnectionString=@"data source=mydb-79be705532\sqlexpress;initial catalog=model;integrated security=true";
conn.Open();
string str_tsql = "select id,tel,name from table1";
SqlCommand cmd=new SqlCommand(str_tsql,conn);
SqlDataReader sqlreader = cmd.ExecuteReader(CommandBehavior.CloseConnection) ;
sqlreader.Read();
OleDbConnection conn2 = new OleDbConnection();
conn2.ConnectionString = @"provider=microsoft.jet.oledb.4.0;" + @"data source=d:\northwind1.mdb;";
OleDbDataAdapter da = new OleDbDataAdapter();
da.InsertCommand = new OleDbCommand();
da.InsertCommand.Connection = conn2;

while (sqlreader.Read())
{
da.InsertCommand.CommandText = "insert into table1 (id,tel,name) values (@id,@tel,@name)";
da.InsertCommand.Parameters.AddWithValue("id" , sqlreader[0].ToString().Trim());
da.InsertCommand.Parameters.AddWithValue("tel" , sqlreader[1].ToString().Trim());
da.InsertCommand.Parameters.AddWithValue("name" , sqlreader[2].ToString().Trim());
da.InsertCommand.Connection.Open();
da.InsertCommand.ExecuteNonQuery();
da.InsertCommand.Connection.Close();
}

sqlreader.Close();


}
}
}