Reputation: 33
I have a database with 2 tables I want to make a copy of the data from the first table to the second one. One table is empty and the other one has the data.
so far my code is:
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Dosimet\\dose_be.mdb");
conn.Open();
string copiar = "INSERT INTO DOSIMETROATIVO (SELECT * FROM DOSIMETRO)";
OleDbCommand cmdcopiar = new OleDbCommand(copiar, conn);
cmdcopiar.ExecuteNonQuery();
conn.Close();
im getting an error on the ExecuteNonQuery (says syntax error on the INSERT INTO instruction)
both DOSIMETROATIVO
(empty) and DOSIMETRO
(with the data) are tables on the same database (dose_be.mdb).
Upvotes: 2
Views: 2316
Reputation: 97101
Remove the parentheses from your INSERT
statement.
INSERT INTO DOSIMETROATIVO SELECT * FROM DOSIMETRO
Upvotes: 5