You can't update two tables with a single sql statement.
What you could do is combine the two statements into a transaction - see
MySQL Transaction[
^]
That way either both statements will be executed or neither of them will (in other words you won't get an update on one table without the corresponding update being done on the other table)
You could put these updates into a stored procedure - see
MySQL Stored Procedure Tutorial[
^] which means you would have a single sql call from your code - see
MySQL :: MySQL Connector/Net Developer Guide :: 6.10.1 Using Stored Routines from Connector/Net[
^]
[EDIT] Here is a partially worked example (
credit[
^])
DELIMITER $$
CREATE PROCEDURE 'sp_entradas_sai'(
IN ident VARCHAR(20), OUT retcode INT)
BEGIN
DECLARE '_rollback' BOOL DEFAULT 0;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET '_rollback' = 1;
START TRANSACTION;
IF '_rollback' THEN
SET retcode = 0;
ROLLBACK;
ELSE
SET retcode = 1;
COMMIT;
END IF;
END$$
DELIMITER ;
Explanation:
The code will create a stored procedure called 'sp_entradas_sai' which takes one input parameter 'ident' - this will be however you are going to identify which row of entradas needs to be updated - the vehicle id or similar. Change the type of this parameter to whatever type your id is on the entradas table.
The procedure will return a single value 'retcode' and integer where 0 means "failed" and 1 means "succeeded".
The procedure declares a handler telling MySQL what to do if there is an error - in this case, set a local variable '_rollback' to 1. If an error occurs MySQL will set this value and then continue to the next line in the procedure.
We then start the transaction ... I've left the queries to do the actual updates for you to do.
When they have done either the changes will be committed to the database (COMMIT) or any partial changes that have happened will be undone (ROLLBACK). That is the end of that transaction and in this case, the end of the procedure.
Note that the value of the return parameter is set according to whether we COMMIT or ROLLBACK.
You can then call this procedure from your code something like this
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = "add_emp";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ident", "car1");
cmd.Parameters["@ident"].Direction = ParameterDirection.Input;
cmd.Parameters.AddWithValue("@retcode", MySqlDbType.Int32);
cmd.Parameters["@retcode"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
var res = cmd.Parameters["@retcode"].Value;