Alessandro Bottoni wrote:
I have a few questions:
- Why I have just Windows DLLs in my /usr/lib/mono/gac/Mono.Data.SqliteClient
directory? Shouldn't I have a few .SO Linux libraries as well?
That are CIL dlls. Therefore the term Windows dll isnt valid anymore
(thats what mono is all about :) )
- Do I have to install the .SO Linux libraries by hand? Which version? I'm
unable to identify the version of SQLite used to create the existing DLL.
To install sqlite under debian you should apt-cache search for sqlite. I
suppose the package name will be something like libsqlite-dev.
Another way to install sqlite is to download the .so from
http://www.sqlite.org/download.html (Scroll down the list and pick the
.so.bz file -
Don't take the first file - thats some command line tool - that way my
first mistake :) ).
Then extract the file and symlink it to libsqlite.so or libsqlite3.so
(depending on what version you choose).
If you still have troubles with Mono.Data.Sqlite then read the following
Blog post of Chris Turchin:
http://turchin.homelinux.net/blogx/PermaLink.aspx/acbc7138-08d6-4a0f-a86d-709748a283d8
- Where is the test suite mentioned by the SQLite docu at
www.go-mono.com/sqlite.html? It should be in
mcs/class/Mono.Data.SqliteTest/Test but I'm unable to find this directory on
my machine.
I am one of the authors of the latest Mono.Data.Sqlite patch. And I also
provided a Test and a UnitTest program, but I just noticed that it has
been removed from the
patch :) Here are the basic code parts :
Notice that the Parameter delimeter in sqlite3 is ':' and that you have
to specify the correct version in your Connection string
//
// SqliteTest.cs
//
// Author(s): Daniel Morgan [EMAIL PROTECTED]
// Chris Turchin [EMAIL PROTECTED]
// Thomas Zoechling [EMAIL PROTECTED]
//
using System;
using System.Data;
using System.Data.Common;
using System.IO;
using Mono.Data.SqliteClient;
namespace Test.Mono.Data.SqliteClient
{
class SqliteTest
{
//static string connectionString =
Version=3,URI=file:SqliteTest.db;
static string connectionString = Version=3,URI=file:SqliteTest.db;
static SqliteConnection dbcon = new SqliteConnection();
static SqliteCommand dbcmd = new SqliteCommand();
[STAThread]
static void Main(string[] args)
{
Console.WriteLine(setting ConnectionString using: +
connectionString);
dbcon.ConnectionString = connectionString;
if (File.Exists(SqliteTest.db))
File.Delete(SqliteTest.db);
Console.WriteLine(open the connection...);
dbcon.Open();
dbcmd.Connection = dbcon;
SetupDB();
Console.WriteLine(SELECTING DATA FROM MONO_TEST);
TestWithoutParameters();
TestSingleParameter();
TestMultipleParameters();
TestUsingDataAdapter();
TestUpdateWithParamsAndEvents();
dbcmd.Dispose();
dbcon.Close();
Console.WriteLine(Done.);
}
static void SetupDB()
{
dbcmd.CommandText = CREATE TABLE MONO_TEST ( NID INT, NDESC
TEXT, EMAIL TEXT);
Console.WriteLine(execute SqliteCommand to CREATE TABLE
MONO_TEST: + dbcmd.CommandText );
dbcmd.ExecuteNonQuery();
Console.WriteLine(inserting data into MONO_TEST...);
dbcmd.CommandText = INSERT INTO MONO_TEST (NID, NDESC,
EMAIL ) VALUES(1,'Mono 1','[EMAIL PROTECTED]');
dbcmd.ExecuteNonQuery();
dbcmd.CommandText =INSERT INTO MONO_TEST (NID, NDESC,
EMAIL ) VALUES(2,'Mono 2','[EMAIL PROTECTED]');
dbcmd.ExecuteNonQuery();
dbcmd.CommandText = INSERT INTO MONO_TEST (NID, NDESC )
VALUES(3,'Mono 3');
dbcmd.ExecuteNonQuery();
dbcmd.CommandText =INSERT INTO MONO_TEST (NID, NDESC )
VALUES(4,'Mono 4');
dbcmd.ExecuteNonQuery();
dbcmd.CommandText = INSERT INTO MONO_TEST (NID, NDESC,
EMAIL ) VALUES(5,'Mono 5','[EMAIL PROTECTED]');
dbcmd.ExecuteNonQuery();
}
static void TestUsingDataAdapter()
{
Console.WriteLine(read and display data using DataAdapter...);
SqliteDataAdapter adapter = new
SqliteDataAdapter(SELECT * FROM MONO_TEST, connectionString);
DataSet dataset = new DataSet();
adapter.Fill(dataset);
DisplayDataSet(dataset);
Console.WriteLine(next test...);
Console.WriteLine(Insert and change data using dataset...);
DataRow dataRow = dataset.Tables[0].NewRow();
dataRow[NID] = 6;
dataRow[NDESC] = New via dataset;
dataRow[EMAIL] = [EMAIL PROTECTED];
dataset.Tables[0].Rows.Add(dataRow);