Table1 iz dataseta ds1 treba kopirati u dataset ds2 i reimenovati je u copyTable1.
Moj kod ne javlja gresku, ali ne znam kako da u bazu, baza2.mdb, dodam novu tabelu, copyTable1.
kod izgleda ovako:
private void btnCopy_Click(object sender, EventArgs e)
{
DataSet ds1 = new DataSet();
DataSet ds2 = new DataSet();
con1 = new System.Data.OleDb.OleDbConnection();
con1.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=D:/baza1.mdb";
con1.Open();
MessageBox.Show(" baza1 OPEN");
string sql1 = "SELECT * From Table1";
da1 = new System.Data.OleDb.OleDbDataAdapter(sql1, con1);
da1.Fill(busicDataSet, "Table1");
con2 = new System.Data.OleDb.OleDbConnection();
con2.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=D:/baza2.mdb";
con2.Open();
MessageBox.Show("baza2 OPEN");
string sql2 = "SELECT * From TableBla";
da2 = new System.Data.OleDb.OleDbDataAdapter(sql2, con2);
daR.Fill(relacijeDataSet1, "TableBla");
DataTable copyTable1 = new DataTable();
copyTable1 = ds1.Tables["Table1"].Copy();
ds1.Tables.Add(copyTable1);
relacijeDataSet1.AcceptChanges();
con1.Close();
con1.Dispose();
con2.Close();
con2.Dispose();
}
|