[Mono-devel-list] Re: Sqlite mono

Everaldo Canuto everaldo_canuto at yahoo.com.br
Mon Mar 28 20:31:15 EST 2005


Hi Daniel,

For sure! :)
Fell free to add this information. Some parts are include by "Evandro M
Leite Jr" and he ask me today about include this information on Mono
Wiki because I use half day to solve his problem with Sqlite :)


Everaldo


Em Seg, 2005-03-28 às 19:29 -0500, Daniel Morgan escreveu:
> 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
> >
> >  
> >
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list





More information about the Mono-devel-list mailing list