In this post i would like to comment out the connection method to .net which is as simple as any of you can imagine. i am using coding method to connect to the firebird database to one of the application in Visual basic .net.
Requirements(Tested on by me):
- Operating System: Microsoft window Vista/XP,
- Microsoft Visual Studio 2008/2005,
- A database already created in Firebird. If you don't know how to create firebird database then follow How to Create Firebird Database tutorial.
- one table in database
- Firebirdclient 2.5.0 should be installed first to support the connectivity which can be downloaded and installed from this link.
Step 1: Start a new Visual basic windows project in Visual studio. so by default one form named form1 will be there.
Step 2: on the coding page of form 1, at the top type the following code
Imports FirebirdSql.Data.FirebirdClient
This will imports the firebird client and firebird sql to perform the rest of operations
Step 2: Create a sub function called "connopen" by writing following code
Sub connopen()
Step 3: Declare the variables:
Dim conn As New FbConnection
Dim csb As FbConnectionStringBuilder
This will declare all the variables required to access the
Step 4: Define the components of Firebird connection string builder:
csb = New FbConnectionStringBuilder
csb.UserID = "SYSDBA"
csb.Password = "masterkey"
csb.Database = "f:\test\testdb.fdb"
csb.ServerType = 1
Step 5: Creatin connection:
conn = New FbConnection(csb.ToString())
Step 6: Opening conection:
conn.open
Step 7: Ending Sub Routine:
End Sub
Now when over you call function connopen() function a connection will setup to firbird database.
To call this function from multiple forms you can create a class and declare connopen() function as public and you can access it from any form in your application.
For any further queries feel free to post them here..i will try to reply them with solution ASAP.
Thanks & Regards,
Amol Verma