Working with DBISAM Using Microsoft .NET
page 5 of 7
by Bhuban Mohan Mishra
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 49042/ 131

C# Code Snippets

Depending on our application need and location of the database (local or remote), the connections may vary.  It can be either done through a DSN or we can use a connection string to connect to the database.

Connection String

For direct connection strings the Keywords play a major role and are case sensitive.  The Connection String Keywords available in DBISAM ODBC Driver are as follows:

·         DRIVER: It specifies the ODBC driver name used.

·         ConnectionType: Depends on the connection, i.e. Local or Remote.

·         CatalogName: Specifies the name of the database.

These were the required Keywords for both Local and Remote Connections.  The following keywords are required only for Remote connections.

·         UID: Specifies the User ID for the remote connection.

·         PWD: Specifies the password for the remote connection.

·         RemoteHostName: Specifies the Host name of the remote Database server.

·         RemoteIPAddress: Specifies the IP address of the remote Database Server.

From the RemoteHostName or RemoteIPAddress above, any one is used.


The different connection types that can be used are listed below.

1.      Connection through a preconfigured DSN

Listing 2

OdbcConnection objODBCCon = new OdbcConnection(“DSN=?”);
//? : Your preconfigured DSN

2.      Connection to the Database present on a local system through a connection string.

Listing 3

string txtConStr = “DRIVER={DBISAM 4 ODBC Driver}”;
txtConStr += “ConnectionType=Local;CatalogName=path”;
//path : The complete path to the folder, where the DBISAM Tables 
//(i.e. *.dat files) are present.
OdbcConnection objODBCCon = new OdbcConnection(txtConStr);

3.      Connection to the Database present on a remote system through a connection string.

Listing 4

string txtConStr = “DRIVER={DBISAM 4 ODBC Driver}”;
txtConStr += “ConnectionType=Remote;CatalogName=employee;”;
//employee : The database present on the Remote Server.
txtConStr += “UID=userid;PWD=password;”;
txtConStr += “”;
// : The IP Address of the Remote Server.
OdbcConnection objODBCCon = new OdbcConnection(txtConStr);

After establishing this connection we can access the database and the tables through a DataSet or DataReader as we usually do in any other ODBC Connections.  The following code shows a way to get all the Table names from a specified folder (dbisamFolder) and display it in a list box (lstAvailable).

Listing 5

string table;
string[] files;
// Gets all the DBISAM Tables from the user Specified folder
files = Directory.GetFiles(dbisamFolder.ToString(),"*.dat");
// Extracts the DBISAM table names from the .dat files
// and excludes the tables.
for(int Count = 0; Count < files.Length; Count++)
table = files[Count].Remove(files[Count].LastIndexOf("."), 4);
table = table.Substring(table.LastIndexOf("\\"+ 1);
// lstAvailable is a ListBox

Now the table names can be used to capture the table into a DataSet and do the required operations.

Listing 6

table = lstAvailable.Items[0].ToString();
OdbcDataAdapter objDA;
DataSet objDS = new DataSet("DbiSam");
objDA = new OdbcDataAdapter("SELECT * FROM " + table, objODBCCon);

View Entire Article

User Comments

Title: Re: new extension db4   
Name: Bhuban M Mishra
Date: 2008-03-24 11:56:12 AM
Hi Nicola,

I went through the Eleviate Software site, but I did not found the details about .db4 files. Might be they have not updated the details of the new version.

According to the following link,

It says that the files still have .dat extension. I do not have access to the latest DB. I think, the way .dat files are accessed, the .db4 files can also be accessed in the same manner.

If possible, you can search for the updated drivers if available for the db4 files.

Title: new extension db4   
Name: Nicola
Date: 2008-03-14 6:21:54 AM
Hallo! i have new version dbisam with new versione.. extension file data is .db4 and not .dat... can u help me?? with new versione.. i want use this code..
thank u soo much
Name: ADAM
Date: 2007-07-16 12:29:55 PM
I looked for a few hours about information about some unkown database file types I had and didnt find anything until I found this article. This article and the help it provided is greatly appreciated. Thanks.
Title: Re: Where do I find DBISAM ODBC Driver?   
Name: Bhuban
Date: 2006-11-03 9:00:08 PM
The ODBC Driver provided by Elevate Software is the only driver available as per my knowledge. I have also used the same. As per your problem is concerned, each table that has BLOB fields must have a .blb file which remains in the same folder as the table. Though I have not worked with BLOBs, there are certain DBISAM viewers available that shows the structure and data in the tables. You can use one of them to check whether the data in the BLOB field is intact.
Title: Where do I find DBISAM ODBC Driver?   
Name: TLR
Date: 2006-11-03 10:30:48 AM
I have found one ODBC Driver from Elevate Software, but it seems to choke whenever I try a select that includes a BLOB column. Can you recommend some other ODBC Driver?
Title: Very Informative Article   
Name: Prasanjit Ahuja
Date: 2006-10-06 5:23:33 AM
Very Informative article. Keep it up.
Title: Panda   
Name: Supriti
Date: 2006-10-05 11:10:09 AM
Thanks for the information about a new database.This may be helpful for me in future.
Title: Working with DBISAM Using Microsoft .NET   
Name: Himanshu Sahoo
Date: 2006-10-03 6:18:10 AM
Nice Article.Well done.

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2021  |  Page Processed at 2021-12-08 4:24:38 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search