Firebird News

Monday, October 06, 2008

Mono Firebird Example updated for Mono 2.0 release

I hope you have Firebird 2.1 already installed with examples :)

Install Monodevelop and Mono
In my case was something like this on Intrepid

$sudo apt-get install mono-gmcs mono-gac mono-utils monodevelop monodoc-browser monodevelop-nunit monodevelop-versioncontrol monodoc-gtk2.0-manual

But is possible to install it from source too

You must download the .Net Provider 2.5 sourcecode
I downloaded this 7zip archive http://downloads.sourceforge.net/firebird/FirebirdClient-2.5.0-Alpha2-src.7z

Then i open the solution NETProvider/FirebirdSql.Data.FirebirdClient.sln in MonoDevelop and compile it with LINUX;MONO symbols and remove all others symbols
in the Solution -> Options -> Configuration Compiler Options area




Create an new C# Console Project
Then add the Firebird .net assembly to the test project
References-> Edit References -> .Net Assembly
browse to the FirebirdSql.Data.FirebirdClient.dll
in my case was in ~/Desktop/NETProvider/source.FirebirdSql/Data/bin/Debug
then click Add button



Fill the Main.cs this way and Build Solution




// Main.cs created with MonoDevelop
// User: mariuz at 12:37 PM 9/12/2008
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
using System;
using System.Data;
using FirebirdSql.Data.FirebirdClient;



namespace firebirdtest
{
class MainClass
{
public static void Main(string[] args) {
string connectionString =
"Database=/var/lib/firebird/2.1/data/employee.fdb;" +
"User=SYSDBA;" + "Password=masterkey;" +
"Dialect=3;character set=NONE;" + "Server=localhost";
IDbConnection dbcon = new FbConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
string sql = "SELECT * FROM employee";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
object dataValue = reader.GetValue(0);
string sValue = dataValue.ToString();
Console.WriteLine("Value: " + sValue);
}
// clean up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}

}
}

then click run after the solution is build and the result should be like this



Thanks Jiri for all his help and .net provider development
Here is the thread where i ported the example from .net provider 1.7 to 2.5

1 comments:

111 said...

WoW shares many wow gold of its features with previously launched games. Essentially, you battle with wow gold cheap monsters and traverse the countryside, by yourself or as a buy cheap wow gold team, find challenging tasks, and go on to higher aoc gold levels as you gain skill and experience. In the course of your journey, you will be gaining new powers that are increased as your skill rating goes up. All the same, in terms of its features and quality, that is a ture stroy for this.WoW is far ahead of all other games of the genre the wow power leveling game undoubtedly is in a league of its own and cheapest wow gold playing it is another experience altogether.

Even though WoW is a Cheap Wow Gold rather complicated game, the controls and interface are done in warhammer gold such a way that you don't feel the complexity. A good feature of the game is that it buy wow items does not put off people with lengthy manuals. The instructions bygamer cannot be simpler and the pop up tips can help you start playing the game World Of Warcraft Gold immediately. If on the other hand, you need a detailed manual, the instructions are there for you to access. Buy wow gold in this site,good for you, BUY WOW GOLD.