MS Access and multiple statements on the same connection
-
Hi, I've just started working with ADO.NET, through which I read from and update a MS Access data base. Now, what I want to do is to first update exactly one row in a data base, and then retrieve the updated row. Currently, this is performed in two steps. However, I want to reduce these two steps into one batch statement like this "UPDATE....; SELECT...." to increase performance. OleDbCommand.ExecuteReader() throws an exception saying "Characters found after end of SQL statement.". What does this mean? I have tried to google my way to an answer, but I get mixed messages and become more and more confused the more I read. Is it possible to batch several statements, and query them on the same connection using MS Access? This is where people seem to disagree. Also, I can't use a stored procedure (which would be ideal btw), because the SELECT-statement returns a value, and that's not possible with MS Access :|. Any help and/or suggestions would be much appreciated! Thanks
-
Hi, I've just started working with ADO.NET, through which I read from and update a MS Access data base. Now, what I want to do is to first update exactly one row in a data base, and then retrieve the updated row. Currently, this is performed in two steps. However, I want to reduce these two steps into one batch statement like this "UPDATE....; SELECT...." to increase performance. OleDbCommand.ExecuteReader() throws an exception saying "Characters found after end of SQL statement.". What does this mean? I have tried to google my way to an answer, but I get mixed messages and become more and more confused the more I read. Is it possible to batch several statements, and query them on the same connection using MS Access? This is where people seem to disagree. Also, I can't use a stored procedure (which would be ideal btw), because the SELECT-statement returns a value, and that's not possible with MS Access :|. Any help and/or suggestions would be much appreciated! Thanks
I have your problem too. So i had to execute each statement seperatly to work e.g to insert a row and get its ID : oleDbCommand = new OleDbCommand ( "insert into myTable ... " , oleDbConnection ); . . . add parameters oleDbCommand.ExecuteNonQuery(); oleDbCommand = new OleDbCommand ( "select @@IDENTITY" , oleDbConnection ); int retValue = Convert.ToInt16( oleDbCommand.ExecuteScalar() );
-
I have your problem too. So i had to execute each statement seperatly to work e.g to insert a row and get its ID : oleDbCommand = new OleDbCommand ( "insert into myTable ... " , oleDbConnection ); . . . add parameters oleDbCommand.ExecuteNonQuery(); oleDbCommand = new OleDbCommand ( "select @@IDENTITY" , oleDbConnection ); int retValue = Convert.ToInt16( oleDbCommand.ExecuteScalar() );