I can successfully import two tables from a paradox database and and add the the data into one access table.From the one paradox table I use the ID field as it is the primary key to link clockings to dates and I made my access primary key equal to the ID field of the Clockd.ID.
How do I append the access table when updating from the paradox database adding just new records
I am a little bit stumped on this
This is how far I have gotten.Any guidance would be appreciated
private void mtrBtnLoad_Click(object sender, EventArgs e)
{
string connStringSource = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Program Files\\Supertime\\db;Extended Properties=Paradox 5.x;";
string connStringDest = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Yellow\\Documents\\paradoxExport.accdb; Persist Security Info=False;";
OleDbConnection connSource = new OleDbConnection(connStringSource);
OleDbConnection connDest = new OleDbConnection(connStringDest);
OleDbCommand cmdSelect = new OleDbCommand(@"Select Clockd.ID, Empmas.EmpNo, Empmas.Name, Clockd.DateTime, Calc0R1, Calc1R1, Calc2R1, Calc3R1, Calc4R1, TotalHours, Target0R1 FROM Empmas INNER JOIN Clockd ON Empmas.EmpNo=Clockd.Empno", connSource);
OleDbCommand cmdIns = new OleDbCommand(@"INSERT INTO Clockd ([ID], EmpNo, [Name], [DateTime], Calc0R1, Calc1R1, Calc2R1, Calc3R1, Calc4R1, TotalHours, Target0R1) VALUES (@ID, @EmpNo, @Name, @DateTime, @Calc0R1, @Calc1R1, @Calc2R1, @Calc3R1, @Calc4R1, @TotalHours, @Target0R1)", connDest);
cmdIns.Parameters.Add(new OleDbParameter("@ID", OleDbType.VarChar, 11,"ID"));
cmdIns.Parameters.Add(new OleDbParameter("@EmpNo", OleDbType.VarChar, 11, "EmpNo"));
cmdIns.Parameters.Add(new OleDbParameter("@Name", OleDbType.VarChar, 11, "Name"));
cmdIns.Parameters.Add(new OleDbParameter("@DateTime", OleDbType.Date, 4, "DateTime"));
cmdIns.Parameters.Add(new OleDbParameter("@Calc0R1", OleDbType.Integer, 8, "Calc0R1"));
cmdIns.Parameters.Add(new OleDbParameter("@Calc1R1", OleDbType.Integer,8, "Calc1R1"));
cmdIns.Parameters.Add(new OleDbParameter("@Calc2R1", OleDbType.Integer, 8, "Calc2R1"));
cmdIns.Parameters.Add(new OleDbParameter("@Calc3R1", OleDbType.Integer, 8, "Calc3R1"));
cmdIns.Parameters.Add(new OleDbParameter("@Calc4R1", OleDbType.Integer, 8, "Calc4R1"));
cmdIns.Parameters.Add(new OleDbParameter("@TotalHours", OleDbType.Integer, 4, "TotalHours"));
cmdIns.Parameters.Add(new OleDbParameter("@Target0R1", OleDbType.Integer, 4, "Target0R1"));
OleDbDataAdapter da = new OleDbDataAdapter(connStringDest,connStringDest);
da.AcceptChangesDuringFill = false;
da.SelectCommand = cmdSelect;
da.InsertCommand = cmdIns;
System.Data.DataSet ds = new System.Data.DataSet();
da.Fill(ds);
da.Update(ds);
DataTable dt = new DataTable();
BindingSource bs = new BindingSource();
bs.DataSource = dt;
dvg1.DataSource = bs;
}