I need to transfer the table's content to the same table located in another database, and I write this simple code using the C# dataAdapter.Fill()
and dataAdapter.Update()
, but it's seems not working like I supposed.
SqlConnection sqlConnection = new SqlConnection(strSqlConnectionString);
SqlConnection sqlConnection2 = new SqlConnection(strSqlConnectionString2);
sqlConnection.Open();
sqlConnection2.Open();
DataSet CustomerDataSet = new DataSet();
SqlDataAdapter sqlDA;
SqlDataAdapter sql2DA;
SqlCommandBuilder sqlCmdBuilder;
SqlCommandBuilder sqlCmdBuilder2;
sqlDA = new SqlDataAdapter("SELECT * FROM Articolo;", sqlConnection);
sqlDA2 = new SqlDataAdapter("SELECT * FROM Articolo;", sqlConnection2);
sqlCmdBuilder = new SqlCommandBuilder(sqlDA);
sqlCmdBuilder2 = new SqlCommandBuilder(sqlDA2);
sqlDA.Fill(CustomerDataSet, "Articolo");
sqlDA2.Fill(CustomerDataSet, "Articolo");
sqlDA2.Update(CustomerDataSet, "Articolo");`
What I want to do is to have the second db(string connection: strSqlConnectionString2) with updated data, taken from the first db, exploiting the functionality of dataAdapter.Fill() + dataAdapter.Update(). Is this possible? And can I do the same things but with Access db as a second db?