sqlserver裡面的數據是根據條件查詢出來的,現在是把查詢出來的數據,給他導入到access數據庫中,但是不知道在C#後台中怎麼寫 跨數據庫去執行insert select,求解啊啊啊啊啊啊
大概的代碼
DataTable table = new DataTable()
SqlConnection sqlconn = new SqlConnection(connectionStr);
sqlconn.Open();
SqlCommand sqlcomm = new SqlCommand("SELECT 字段 from sqlserver中的表,sqlconn);
SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlcomm);
sqlAdapter.Fill(table);
foreach (var row in table.Rows)
{
string accsql = "insert into access表(字段...) values('" + row[字段1] + "', " + row[字段2] ...
OleDbCommand cmd = new OleDbCommand(accsql, access的con);
cmd.ExecuteScalar();
}