Connecting to InterBase using an Active Server Page (ASP)

By: Quinn Wildman

Abstract: This articles provides detailed instructions, with numerous examples, on connecting to InterBase using an ASP.

Introduction

This article gives complete steps on how to connect to InterBase using an ASP, of which the most popular is Microsoft Internet Information Server (IIS). However, if you are familiar with the basics of connecting to an ODBC data source using an ASP, you probably only need to know a couple things and can probably ignore the rest of this article. So, if you are familiar with the basics of connecting to an ODBC data source using an ASP read on. Otherwise, skip to the Detailed Instructions section..

The Basics

  • An ASP connection looks to InterBase like a remote connection, so you need a remote license.
  • Create a System DSN and make the entry for the database use a remote connection. If the database is on the same CPU as the server, the remote connection can be to localhost.
  • Create a Microsoft Data Link file that connects to the System DSN you just created and verified you can connect with it.
  • Open the Microsoft Data Link file in Notepad. The connect string you need will be shown.
     Not following all these steps generally results in the error Optional feature not implemented.

Detailed Instructions

Install ADO. If you have Windows 2000, it comes pre installed. If you don't have it installed, it is included with various Microsoft products and  is also included with the Microsoft MDAC which can be downloaded from  http://www.microsoft.com/data/

Select Data Sources (ODBC) from Control Panel.

Create a new System DSN. If you have InterBase 6 select the Easysoft IB6 ODBC driver. If you have InterBase 5,  select the INTERSOLV InterBase ODBC Driver.

Give the DSN any name of your choosing. Make the database name point to your database using a remote connection string. If the database is on the same CPU as your server, you can use localhost, or the server name. If you are using the Easysoft driver, click Test to make sure what you have entered works.

Next, you'll create a Microsoft Data Link file that uses this ODBC driver. If you have Windows 95/98/NT, you can create a new Microsoft Data Link file from Windows Explorer by select it in the New Menu. Windows 2000 users should read  http://community.borland.com/article/0,1410,27138,00.html for how to create a Microsoft Data Link File with Windows 2000. Once you have your Microsoft Data link file created, double click on it. Select the Provider Tab, and select an OLE DB Provider of Microsoft OLE DB Provider for ODBC Drivers.

Click Next. Make the data source name be the one you just created. Enter your user name and Password and check Allow saving password. Finally click Test Connection to make sure what you have done works.

Finally, open your Data Link file in Notepad. It should look as follows:

[oledb]
; Everything after this line is an OLE DB initstring
Provider=MSDASQL.1;Password=masterkey;Persist Security Info=True;User ID=sysdba;Data Source=ibdsn1

The last line should work as your connect string for your ASP connection.

Examples

Below are various examples of connecting to an InterBase database using an ASP. For a discussion of what each parameter in the connect string means see  http://support.microsoft.com/support/kb/articles/q193/3/32.asp

Example 1:

var oConn;
var oRs;
// Create ADO Connection Component to connect with sample database
oConn = Server.CreateObject("ADODB.Connection");
oConn.Open("Provider=MSDASQL.1;Password=masterkey;Persist Security Info=True;User ID=sysdba;Data Source=ibdsn1");
oRs = oConn.Execute("select * from employee");

All further examples just show the Open line. All the remaining lines are the same:

Example 2:

oConn.Open("Provider=MSDASQL.1;Password=masterkey;User ID=sysdba;Data Source=ibdsn1");

Example 3:

oConn.Open("Provider=MSDASQL;Password=masterkey;User ID=sysdba;Data Source=ibdsn1");

Example 4:

oConn.Open("Provider=MSDASQL;Password=masterkey;User ID=sysdba;Data Source=ibdsn1;db=localhost:c:ibdbsclarify.gdb");

Example 5:

oConn.Open("Provider=MSDASQL;Password=masterkey;User ID=sysdba;Data Source=ibdsn1;initial catalog=localhost:c:ibdbsclarify.gdb");

Example 6:

oConn.Open("Provider=MSDASQL;Password=masterkey;User ID=sysdba;Dsn=ibdsn1");

Example 7:

oConn.Open("Provider=MSDASQL;Password=masterkey;UID=sysdba;Dsn=ibdsn1");

Example 8:

oConn.Open("Provider=MSDASQL;Pwd=masterkey;UID=sysdba;Dsn=ibdsn1");

Example 9:

oConn.Open("Driver={Easysoft IB6 ODBC};Pwd=masterkey;Uid=sysdba;server=localhost:;db=localhost:c:ibdbsclarify.gdb");

Example 10:

oConn.Open("Provider=MSDASQL;Pwd=masterkey;Uid=sysdba;Dsn=ibdsn1;database=localhost:c:ibdbsclarify.gdb");

Example 11:

oConn.Open("Provider=MSDASQL;Pwd=masterkey;Uid=sysdba;Dsn=ibdsn1;dbq=localhost:c:ibdbsclarify.gdb");

Example 11:

//If the username and Password are specified in the DSN, you can specify only the user name
oConn.Open("Provider=MSDASQL;UID=sysdba;Dsn=ibdsn1");

Example 12:

oConn.Open("Driver={Easysoft IB6 ODBC};Pwd=masterkey;Uid=sysdba;database=localhost:c:ibdbsclarify.gdb");

Example 13:

oConn.Open("Driver={INTERSOLV InterBase ODBC Driver (*.gdb)};Pwd=masterkey;Uid=sysdba;db=localhost:c:ibdbsclarify.gdb");

Example 14:

oConn.Open("Driver=Easysoft IB6 ODBC;Pwd=masterkey;Uid=sysdba;db=localhost:c:ibdbsclarify.gdb");

Server Response from: ETNASC03