I have 2 databases: Database1 & Database2, I set it on the button. When I click the button I will update and insert at the same time.
In Database2 I want to INSERT a record. In Database1 I want to UPDATE a record.
Here's my code:
Database2
connection1.Open();
OleDbCommand cmd = connection1.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into TestTable2 values ('" + textBox1.Text + "','" + comboBox3.Text + "','" + textBox3.Text + "_" + comboBox2.Text + "_" + textBox4.Text.Replace("/", "") + ".pdf" + "','" + comboBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + newPath + textBox3.Text + "_" + comboBox2.Text + "_" + textBox4.Text.Replace("/", "") + ".pdf" + "','" + comboBox1.Text + "','" + textBox33.Text + "','" + textBox45.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox7.Text + "')";
cmd.ExecuteNonQuery();
connection1.Close();
Database1
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query = "update TestTable1 set Status='" + "Done" + "' where Directory='" + textBox2.Text + "'";
command.CommandText = query;
command.ExecuteNonQuery();
connection.Close();
My problem is when doing update and insert it's very slow. it keeps loading at least 12 to 18 secs. I am using MS Access.