SQLite Forum

SQLite using ADO.Net with Types Other Than Long, Double, and String
Login

SQLite using ADO.Net with Types Other Than Long, Double, and String

(1) By Jim Black (jblackjim) on 2021-03-01 21:32:47 [source]

I have an application that uses ADO.NET with SQL Server, and I now want to have it support SQLite without causing a complete rewrite. The more rigid .NET data types (e.g. DateTime, Single, Int32) are everywhere in in-memory DataTables in the code, so I need to continue using those types in memory. If I define and fill these tables via DataAdapter.FillSchema and DataAdapter.Fill with a SQLite connection, it makes all columns String, Long, or Double. If I convert the columns in these in-memory DataTables to (DateTime, Single, and Int32) and then try to call DataAdapter.Update back to SQLite with in-memory data types of DateTime, Single, or Int32, I get concurrency exceptions. So I convert the types back to (String, Long, and Double) right before the call to DataAdapter.Update. But this seems to mess up the underlying SQL and parameters in the Update Command. Is there a practical ADO.NET solution for in-memory data types differing from Long, String, and Double types?