[Mono-list] Using SQLite, Mono and Monodevelop

2005-06-22 Thread Alessandro Bottoni
I'm trying to use monodevelop 0.7, mono 1.1.8.1pre on a Debian 3.1 (brought to 
the latest stable version available on debian.meebey.net by apt-get) for 
building a small DB-based application with SQLite n3.2.1.

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?

- 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.

- 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.

In short: is it available any (up-to-date and reliable) tutorial about setting 
up the system and developing a small SQLite+Mono application?

Many thanks for your attention
---
Alessandro Bottoni
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Using SQLite, Mono and Monodevelop

2005-06-22 Thread Thomas Zoechling

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);
   

Re: [Mono-list] Using SQLite, Mono and Monodevelop

2005-06-22 Thread Alessandro Bottoni
Many thanks for your help, Thomas.
This is my first attempt to use Mono and Monodevelop so I'm still confused 
about their real structure.

Anyway, this platform is fantastic:
- Debian is fantastic. Thanks to apt-get and Synaptic you can go back and 
forth between program versions without worring about dependencies.
- Mono is fantastic: it is like Java but it is faster (at least on my Debian), 
more elegant (thanks to C#) and, most important, it is a real Open Source 
product.
- Monodevelop is fantastic: it is easy to use and feature-rich. It is almost 
better than KDevelop and Anjuta (that are years older and should be much more 
mature than Monodevelop).
- SQLite is fantastic: it is like MS Jet but much more elegant and completely 
Open Source.
- GTK# and Glade/libglade are fantastic: a very strong challenger for 
Windows.Forms (and can even load a XML UI definition file at run-time).

Now I have a couple of good news to tell to my friends and collegues the next 
time we go out for a beer :-)

Many thanks for your valuable work, to you and all of the people involved in 
the development of Mono.
---
Alessandro Bottoni
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list