Idan Arye
Idan Arye

Reputation: 12633

Getting more info from System.Data.SQLite.SQLiteException

When System.Data.SQLite encounters an SQL syntax error, the only relevant info the Message property of SQLiteExcption gives is the name of the SQL error and the keyword/symbol near it. Is there a way to get more info about the error - namely, the exact location(or range) in the CommandText string where the error occurred?

It doesn't have to be from the SQLiteException - getting that info from the SQLiteCommand or the SQLiteConnection will also help.

Upvotes: 3

Views: 5853

Answers (1)

Sem Vanmeenen
Sem Vanmeenen

Reputation: 2151

This exception is caused by a syntax error in your SQL statement. C# itself can't give you more information. It just passes your query to SQLite. SQLite then parses your query and generates a syntax error. That error is catched by C# and packaged in a SQLiteException. Thus, you are not asking that C# gives you more information but that SQLite does.

Unfortunately, as far as I know (and after some googling) it seems SQLite can't give you more information. The only other option I found was a program called SQLite Developer. I haven't tried it but it says it has (besides a whole other bunch of features) a syntax checker. The screenshot of that checker on that page indicates it underlines your syntax errors in your SQL statements. There is a paying version and freeware lite version. You'll have to see for yourself which one is sufficient.

Upvotes: 1

Related Questions