Search code examples
c#.netsqliteprepared-statement

Is there any way to see the actual command text of a parameterized SqliteCommand?


In my code I am using parametized queries, for example:

INSERT INTO table_name VALUES(?,?,?,?);

I then add the parameters programatically (for example the integer values 1,2,3,4), execute the command and everything is lovely, however I would like to add a log output which records the actual SQL executed:

INSERT INTO table_name VALUES(1,2,3,4);

And I can't currently see a way to do this.

I'm using .NET 3.5, C# 3 and the up-to-date libraries from http://system.data.sqlite.org

Any help would be very much appreciated.


Solution

  • Someone correct me if I'm wrong (I don't have the source code here), but iirc there is no "actual command text". I'm pretty sure the DB's parser turns your inputs (statement + parameters) directly into a parse tree, without an intermediate human-readable SQL statement.