This project is read-only.

Difference between Statement.StepAsync and Database.ExecuteStatementAsync

Nov 9, 2013 at 2:25 PM

is there any significant difference between Statement.StepAsync and Database.ExecuteStatementAsync in sqlite-winrt?

SELECT Statements have to use StepAsync of course to get information about whether there are more results or not. All other queries (INSERT, UPDATE, CREATE, etc.) can choose if they are executed directly (Database.ExecuteStatementAsync) or use a pre-compiled Statement as well. The result is always the same. Is this right?

But are there any other differences? Is one method significantly faster than the other? Or has one method any other advantages about the other?

As far as I know precompilied statements have the advantage that SQL injections are more unlikely and that they can be cached (more speed on multiple execution of the same query). But these are advantages which do not really count in a WP app, do they?

Is it just a question of which method I do like better or are there real pros and cons?

Thank you very much!
Nov 11, 2013 at 1:14 PM

There is no significant performance advantage for one over the other. If your statement does not return any values, then there will be an infinitesimal perf advantage with ExecuteStatementAsync.

The real difference is in the correct formatting of the queries. The SQL statement for INSERT, UPDATE etc will obviously have data values in it. You can setup the correct statement by formatting the SQL command as a string and then execute it with ExecuteStatementAsync, but that often leads to errors with data values that include quotes or spaces. Far easier to define the SQL command string using anonymous or named parameters and then insert the values using the BindxxParameter At(..) or BindxxParameterWithName(..) to insert the values – correctly takes care of the formatting for you!

Nov 11, 2013 at 1:56 PM
Thank you very much!