1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
* SQL Lite Data Provider
<ul>
<li>ADO.NET Data Provider for
the <a href"http://www.hwaci.com/sw/sqlite/">SQL Lite</a> which
is an embeddable SQL database engine</li>
<li>From the SQL Lite web page: SQLite is a C library that
implements an embeddable SQL database engine. Programs that link with
the SQLite library can have SQL database access without
running a separate RDBMS process. The distribution
comes with a standalone command-line access program (sqlite) that
can be used to administer an SQLite database and which serves
as an example of how to use the SQLite library. SQLite is not a client library
used to connect to a big database server. SQLite is the server. The SQLite
library reads and writes directly to and from the database files on disk.</li>
<li>SQL Lite can be downloaded
from <a href="http://www.hwaci.com/sw/sqlite/download.html">here</a>.
binaries exist for Linux and Windows. sqlite.dll on Windows
and sqlite.so on Linux. The source code is available too.</li>
<li>Exists in namespace and assembly Mono.Data.SqliteClient</li>
<li>Created by Vladimir Vukicevic so he could have a database of
thumbnail images for mPhoto. mPhoto is GUI application
for cataloging images. mPhoto runs on Mono
and uses <a href="http://www.go-mono.com/gtk-sharp.html">GTK#</a> for its GUI.</li>
<li>Bugs with Mono or the data provider should be reported
in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>. If you
do not have Bugzilla user account, it is free
and easy to
create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
</ul>
** Current Status
<ul>
<li>Able to connect, execute commands, and retrieve data...</li>
<li>Works in mPhoto by providing access to a SQL Lite database to store images.</li>
</ul>
** Action Plan
<ul>
<li>Create a DataAdapter for SQL Lite named SqliteDataAdapter that can be used to
Fill a DataTable in a DataSet</li>
<li>Get the method GetSchemaTable() in class SqliteDataReader to return a DataTable
that works</li>
</ul>
** Testing
<ul>
<li>Have a working mcs and mono</li>
<li>Make sure Mono.Data.SqliteClient.dll was built and is installed
in the same place as the mono class libraries.</li>
<li>If you do not have <a href"http://www.hwaci.com/sw/sqlite/download.html">SQL Lite</a>,
download it. There are binaries for Windows and Linux.</li>
<li>There is a test named SqliteTest.cs found at mcs/class/Mono.Data.SqliteTest/Test</li>
<li>Has a connection string format of "URI=file:some/path". For example,
the connection string "URI=file:SqliteTest.db" will use the database file
named SqliteTest.db, if it does not exist, the file will be created.</li>
<li>C# Example:
<pre>
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 = 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 = (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;
}
}
</pre>
</li>
<li>Building C# Example:
<ul>
<li>Save the example to a file, such as, TestExample.cs</li>
<li>Build on Linux:
<pre>
mcs TestExample.cs -r System.Data.dll \
-r Mono.Data.SqliteClient.dll
</pre>
</li>
<li>Build on Windows via Cygwin:
<pre>
mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
TestExample.cs \
-lib:C:/cygwin/home/MyHome/mono/install/lib \
-r System.Data.dll \
-r Mono.Data.SqliteClient.dll
</pre>
</li>
</ul>
</li>
<li>Running the Example:
<pre>
mono TestExample.exe
</pre>
</li>
</ul>
|