Developping Database Application on MonoDevelop with SQLite3 on Ubuntu for Windows

Sunday, 2 October 2011, 581

Firstly install MonoDevelop with Ubuntu Software Manager and Database Plugin for MonoDevelop (monodevelop-database) plugin.

Download SQLite-x.x.xx.x-managedonly-binaries.zip from sqlite.phxsoftware.com. And extract files.

Open MonoDevelop and Create new solution. Open Project -> Edit References from Menu bar. Select .NET Translate, add System.DataSQLite.dll file. And select “System” and “System.Data” from “Packets tab”.

Now drag and drop a “textView” component, a “button” component, then write your code Clicked function on “Button Signals” event.

Your code may be like this:


protected virtual void OnButtonClicked (object sender, System.EventArgs e)
{
var path_to_db=@"sqlite3-db-file.sqlite3";
SQLiteConnection sqlite_connection=new SQLiteConnection("Data Source="+path_to_db+";Version=3;New=True;Compress=True;");
SQLiteCommand sqlite_command=sqlite_connection.CreateCommand();
sqlite_connection.Open();
sqlite_command.CommandText="SELECT name FROM people WHERE surname LIKE '%eken%'";
SQLiteDataReader sqlite_datareader=sqlite_command.ExecuteReader();
while(sqlite_datareader.Read()){
textview1.buffer.text=sqlite_datareader.GetString(1);
}
sqlite_command.Dispose();
sqlite_command=null;
sqlite_datareader.Close();
sqlite_datareader=null;
sqlite_connection.Close();
sqlite_connection=null;
}

Select “Project” menu from menu bar, then select “Make Packet”, “Archive of Binaries” and click “next”, and “next” again. Choose “Microsoft Windows” on “Target platform” on “Packet Settings” then click make button.
This article will be finished soon…
 


Leave a comment
Name(required)
Mail (will not be publishing) (required)
Website