Google
 

Monday, January 10, 2005

Connecting to Firebird with C#

 using System;

using System.Data;
using FirebirdSql.Data.Firebird;

public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Database=C:PROGRAM FILESFIREBIRDEXAMPLESEMPLOYEE.GDB;" +
"User=SYSDBA;" +
"Password=masterkey;" +
"Dialect=3;" +
"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;
}
}

1 comment:

Dan said...

I have started a site devoted to using Firebird in .NET. You can take a look at http://www.dotnetfirebird.org.