[Mono-devel-list] Re: Sqlite mono

Daniel Morgan danielmorgan at verizon.net
Mon Mar 28 19:29:38 EST 2005


Hello Listas and Everaldo,

Can I add the info you provided about SQL Lite to the Mono wiki?   I 
will credit you.  The info would fall under the GPL Documentation License.

Listas Evandro (Não use este endereço para mensagens pessoais) wrote:

>Thanks to everaldo, everything runs smoothly.
>
>using System;
>using System.Data;
>using Mono.Data.SqliteClient;
>
>public class Test {
>    public static void Main(string[] args) {
>        
>        // Please, use mono >= 1.1.4
>        //----------------------------------------------------------------
>        // Sqlite 3
>        // Get sqlite DLLs from: http://www.sqlite.org/download.html
>        //
>        // Windows: put sqlite3.dll in the same directory or in the
>system path
>        //
>        // Linux, as root
>        // apt-get install sqlite3
>        // (just in case)
>        // ln -s /usr/lib/libsqlite3.so.0.8.6 /usr/lib/libsqlite3.so.0 
>        // ldconfig
>        //----------------------------------------------------------------
>        // Sqlite 2
>        // Get sqlite DLLs from: http://www.sqlite.org/download.html
>        //
>        // Windows: put sqlite.dll in the same directory or in the system path
>        //
>        // Linux, as root
>        // apt-get install sqlite
>        // (just in case)
>        // Linux: apt-get install sqlite
>        // ln -s /usr/lib/libsqlite.so.0.8.6 /usr/lib/libsqlite.so.0
>        // ldconfig
>        //----------------------------------------------------------------
>        // Compile using:
>        // mcs sqlite.cs  -r:System.Data.dll -r:Mono.Data.SqliteClient.dll
>        // run as:
>        // mono sqlite.exe
>
>        string connectionString = "version=3,URI=file:MonoTest.db"; //
>For version 3
>        //string connectionString = "URI=file:test.db"; Uncomment for
>sqlite version  2
>
>        IDbConnection dbcon;
>        dbcon = new SqliteConnection(connectionString);
>        dbcon.Open();
>        IDbCommand dbcmd = dbcon.CreateCommand();
>
>        string sql = "";
>
>        try{
>            sql = @"DROP TABLE employee";
>            dbcmd.CommandText = sql;
>            dbcmd.ExecuteNonQuery();
>        }catch{}
>
>        sql =@"CREATE TABLE employee (
>                        firstname varchar(32),
>                        lastname varchar(32))";
>        dbcmd.CommandText = sql;
>        dbcmd.ExecuteNonQuery();
>
>        sql = @"INSERT into employee values('Jack', 'Black')";
>        dbcmd.CommandText = sql;
>        dbcmd.ExecuteNonQuery();
>        sql = @"INSERT into employee values('Tom', 'Harper')";
>        dbcmd.CommandText = sql;
>        dbcmd.ExecuteNonQuery();
>        sql = @"INSERT into employee values('http://www.simios.org/', 'Team')";
>        dbcmd.CommandText = sql;
>        dbcmd.ExecuteNonQuery();
>
>        sql =
>           "SELECT firstname, lastname " +
>           "FROM employee";
>        dbcmd.CommandText = sql;
>        IDataReader reader = dbcmd.ExecuteReader();
>        while (reader.Read()) {
>            string FirstName = (string)reader[0];
>            string LastName = (string)reader[1];
>            Console.WriteLine("Name: " +
>                FirstName + " " + LastName);
>        }
>        // clean up
>        reader.Close();
>        reader = null;
>        dbcmd.Dispose();
>        dbcmd = null;
>        dbcon.Close();
>        dbcon = null;
>    }
>}
>
>
>--
>Evandro M Leite Jr
>PhD Student
>School of Mathematics
>University of Southampton
>SO17 1BJ
>United Kingdom
>
>  
>




More information about the Mono-devel-list mailing list