Using C# and SQlite

  • Thread starter Thread starter Roland Bengtsson
  • Start date Start date
R

Roland Bengtsson

I have an application that I want to use an embedded database in. I
started with MySQL and ODBC (client server model) but want to change
that. I found SQLite http://www.sqlite.org and found it promising, a
single dll-file contains all the needed functions.

I'm new to C# but I found that I have to write C# functions marked
with unsafe keyword do call an external dll-file. I tried to add an
reference to sqlite.dll in Visual .NET 2003 but I got an error. Then I
found a wrapper on
http://www.phpguru.org/static/SQLite.NET.html but I failed to compile
that to.
the line

using Hlib;

got an error. The compiler don't know what Hlib is.
I add the reference to SQLiteClient.dll before compiling the project
sqlLiteTest.

So what are my options?
 
Roland,

The DLL is most likely an unmanaged DLL that exports functions. In
order to call these, you will want to use the P/Invoke layer. This does not
require the unsafe keyword (although it can help in some situations).

However, for data access, I would recommend against doing this, and
going with the .NET data provider model. In the event that your application
grows and you need a more powerful database, it will be easier to make the
transition to another data provider which follows the data model. To that
end, you might want to try mySql. It has a provider that follows the model,
and it is free (to my knowledge).

Hope this helps.
 
Back
Top