Mono Class Library: Namespaces

Mono.Data.SqliteClient Namespace

The Mono.Data.SqliteClient provides a data adapter for the Sqlite (www.sqlite.org) database, versions 2 and 3. [Edit]

Remarks

This assemby provides a wrapper around the native Sqlite library from www.sqlite.org. The Sqlite library must be separately installed to access Sqlite databases.

SQLite has a notable oddity: table cell data does not retain what kind of data it was. Everything is stored as either a long, double, string, or blob. And in SQLite version 2, everything is stored as a string. So you need to be careful about avoiding casting values returned by SQLite without checking the type of the value returned.

See Mono.Data.SqliteClient.SqliteConnection.ConnectionString for information on the connection string format for this data provider.

C# Example
using System;
 using System.Data;
 using Mono.Data.SqliteClient;
 
 public class Test
 {
    public static void Main(string[] args)
    {
       string connectionString = "URI=file:SqliteTest.db";
       IDbConnection dbcon;
       dbcon = (IDbConnection) new SqliteConnection(connectionString);
       dbcon.Open();
       IDbCommand dbcmd = dbcon.CreateCommand();
       // requires a table to be created named employee
       // with columns firstname and lastname
       // such as,
       //        CREATE TABLE employee (
       //           firstname varchar(32),
       //           lastname varchar(32));
       string sql =
          "SELECT firstname, lastname " +
          "FROM employee";
       dbcmd.CommandText = sql;
       IDataReader reader = dbcmd.ExecuteReader();
       while(reader.Read()) {
            string FirstName = reader.GetString (0);
            string LastName = reader.GetString (1);
            Console.WriteLine("Name: " +
                FirstName + " " + LastName);
       }
       // clean up
       reader.Close();
       reader = null;
       dbcmd.Dispose();
       dbcmd = null;
       dbcon.Close();
       dbcon = null;
    }
 }

To build and run the example:

[Edit]

Classes

TypeReason
SqliteBusyExceptionDocumentation for this section has not yet been entered.
SqliteClientFactoryDocumentation for this section has not yet been entered.
SqliteCommandRepresents a command to execute on the database.
SqliteCommandBuilderDocumentation for this section has not yet been entered.
SqliteConnectionRepresents a connection to a database.
SqliteConnectionStringBuilderDocumentation for this section has not yet been entered.
SqliteDataAdapterDocumentation for this section has not yet been entered.
SqliteDataReaderThe DataReader represents a table of results returned from a query.
SqliteDataSourceEnumeratorDocumentation for this section has not yet been entered.
SqliteExecutionExceptionDocumentation for this section has not yet been entered.
SqliteParameterDocumentation for this section has not yet been entered.
SqliteParameterCollectionDocumentation for this section has not yet been entered.
SqliteRowUpdatedEventArgsDocumentation for this section has not yet been entered.
SqliteRowUpdatingEventArgsDocumentation for this section has not yet been entered.
SqliteSyntaxExceptionDocumentation for this section has not yet been entered.
SqliteTransactionDocumentation for this section has not yet been entered.

Delegates

TypeReason
SqliteRowUpdatedEventHandlerDocumentation for this section has not yet been entered.
SqliteRowUpdatingEventHandlerDocumentation for this section has not yet been entered.