Working with DBISAM Using Microsoft .NET
Published: 03 Oct 2006
In this article Bhuban provides a brief overview about DBISAM and the different ways by which we can interact with the database using Microsoft .NET.
by Bhuban Mohan Mishra
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 49052/ 132


DBISAM is a word that may seem new for many of us and many would be astonished to know that it is a database.  Like any other database, it has the ability to maintain huge amounts of data.  This article aims at providing an overview of DBISAM and the ways we can interact with the database through .NET.  Let us first discuss about some of the aspects of DBISAM.


DBISAM is an embedded database engine which is available for programming languages that can use ODBC for data access.  DBISAM can be used as a single-user, multi-user or client-server engine.

General Architecture

DBISAM is session based where each session is equivalent to a virtual user.  In a given application there can be many active sessions.  The sessions are of 2 types.

·         Local Session: A local session can directly access the database tables via Windows or Linux APIs to the local storage medium.

·         Remote Session: A remote session uses sockets to communicate to a database server over a network using TCP/IP protocol.

The main drawback of DBISAM is that it does not support Referential Integrity.


DBISAM uses the physical directories in Operating System’s file system to represent databases. The tables in DBISAM are represented by three physical files in the database.

·         .dat (Data Files) which are the actual tables in the Database that store records.

·         .idx (Index Files) which store index definitions and pages.

·         .blb (BLOB Files) that store BLOB blocks related to tables.

Data Types

The data types used in DBISAM are also supported by other databases or relational databases, but with some exceptions.  A comparison between the data types of DBISAM and SQL Server is given below.

Listing 1

Data Type


SQL Server Equivalent


Fixed length fields that can store up to 512 characters. The trailing blank spaces are automatically trimmed from any strings entered into string fields.



Same as string fields with the exception that trailing blank spaces are not automatically removed from any strings entered into them.




Same as string fields with the exception that they are fixed at 38 bytes in length and are always used to store the string representation of a GUID value.



Fixed in length and can store up to 512 bytes in a single field.



Variable in length and may contain up to 2 gigabytes of data.



Variable in length and may contain up to 2 gigabytes of data minus a NULL terminator.



Variable in length and may contain up to 2 gigabytes of data.



Date fields contain dates only.



Time fields contain times only.



Contain both a date and a time.



Contain logical True/False values.



Contain 16-bit, signed integers.



Contain 16-bit, unsigned integers.



Contain 32-bit, signed integers.



Contain 32-bit, signed integers.

INT with Identity


Contain 64-bit, signed integers.



Contain 64-bit floating-point numbers (doubles).



Currency fields are the same as Float fields.



BCD fields contain a 34-byte TBcd type.



Working with DBISAM

After knowing a bit about database structure, let us put our hands on the programming part with relation to .NET.  As every database has accepted SQL as the standard language for querying, so too has DBISAM.  We do not need to worry about syntax; our same old concept on SQL will work fine here.  Now to connect to the DBISAM Database from our application, we need the DBISAM ODBC driver.  It is an ODBC level 3 driver.  The driver works with Microsoft Data Access Components (MDAC) version 2.7 or higher and many other applications including .NET Applications.

Missing Features

There are still a few things missing from the driver like support for bulk operations and a few ODBC extended scalar functions (UNION, INTERSECT, LIKE, etc).

Using ODBC Driver

To use the ODBC Driver we can either setup a DSN which we access from our application or can directly access the database through a connection string from our application.

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);


There are many other ways of dealing with the DBISAM Tables and far more ways to work with DBISAM Database itself, starting from Database Locking to Multithreaded applications with a blend of Local and Remote Sessions.  It supports a wide range of Development Platforms, Programming Languages and Reporting Tools.  This is a small effort to make you familiar with this Database.

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-04 6:08:40 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search