JG Vimalan's Blog

It is all about coding!

Connecting to an Interbase database using Enterprise Library 3.1

Inorder to connect to Interbase using Enterprise Library 3.1, the following steps should be followed.

1. Install ADO.NET 2.0 Driver for InterBase (I installed AdoDbxCleint, which is available over internet)

2. Edit the machine.config file from the C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG directory. Add the following line in the section labeled

<DbProviderFactories>

<add name = “Interbase ADO 2.0 provider” …… (This you can find when you install the provider)>

3. Launch Enterprise Library Configuration (you need to install Enterprise library for this)

4. Configure new Data Access Application block as shown below.

Steps

5. So, when you save this, you will get a .config file.

6. Add this config file in your project.

7. Add the following references in your project to make use of Enterprise Library DAL

Microsoft.Practices.EnterpriseLibrary.Common; Microsoft.Practices.EnterpriseLibrary.Data;

8. Put a simple code:  

Database db = DatabaseFactory.CreateDatabase();

string sql = “SELECT Name, Age FROM STUDENT”;

DbCommand command = db.GetSqlStringCommand(sql);

using (IDataReader reader = db.ExecuteReader(command))

{

while (reader.Read())

{

record.SubItems[0].Text = reader[0].ToString();//Get Name record.SubItems[1].Text = reader[1].ToString();//Get Age ….

}

reader.Close();

}      

 Thats all!!!

Happy coding…

 Regards,

JG Vimalan

Advertisements

September 27, 2009 - Posted by | Interbase

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: