interbase 7.5 and visual studio 2010

1.9k Views Asked by At

I spent the last few days searching for a solution to develop a c# application which connects to an Interbase 7.5 database. I tried the db driver from here and the provided ado.net driver ("Interbase Connectivity Drivers"). When I run "Connect to Database" in VS2010 there is no option to connect to IB. So what do I need to do/install/configure to use this driver in VS?

OS is WinXP SP3 running in a VM

3

There are 3 best solutions below

1
On

Connect to Database ( from VS Server Explorer ) shows you a small dialog, in there you can select as data source then you can specify in the drop down below the provider you want to use, if even after selecting above you still do not see the Interbase ADO.NET connector you can surely select ODBC and use an ODBC data source, after having created it from the control panel.

1
On

If you installed the 2.0 driver then there is a how to file called ADO_NETreadme.htm in the install directory. It details how to install and run the driver including code to connect it to .net objects. It adds how to add the dll to the project and other setup issues. This driver also assumes interbase is installed on the machine it is running on as it will need the admin.ib file for authentication. I followed the readme document and connected successfully without the use of ODBC.

using Borland.Data;  //IB Database Connectivity

DbConnection dbconn = new TAdoDbxConnection();
string database = DatabasePath.tostring();
dbconn.ConnectionString = "DriverName=Interbase;Database="Datbasepath";RoleName="Password";User_Name="Userid"   + "SQLDialect=3;MetaDataAssemblyLoader=Borland.Data.TDBXInterbaseMetaDataCommandFactory,Borland.Data.DbxReadOnlyMetaData,Version=11.0.5000.0,Culture=neutral,"    + "PublicKeyToken=91d62ebb5b0d1b1b;GetDriverFunc=getSQLDriverINTERBASE;LibraryName=dbxint30.dll;VendorLib=GDS32.DLL";

try { dbconn.Open(); }
catch (Exception ex)
{ throw (ex); }

DbCommand cmd = dbconn.CreateCommand();
cmd.CommandText = "Select SQL statement..."
DbDataReader myreader = cmd.ExecuteReader();

or you can

cmd.CommandText = "Delete or Append...SQL"
cmd.ExecuteNonQuery();

You can then set up a dataset and read into it any data from the database using a DbDataReader and standard bindingsource. From there it is simple standard .Net data manipulation.

0
On

I have added another answer because the first answer is valid but is only valid in 80% of the scenarios if using the older driver. I have updated this to include it working for Visual Studio 2013.

Make sure you get the latest InterBase_ADO.NET from embarcadero. The version I updated to was version 16.0.4327.44959 of Borland.Data.AdoDbxClient.dll. (Right click on file, properties, details to see version number). The install also creates a x64 version folder for 64bit even though I did not use it. I targeted x86 with no issues.

This ADO.NET install is not necessary to do on every machine – you just need to include the below files in your project and have Interbase installed on the machine you are running on. I only installed the driver on my development computer.

The install will extract all the necessary files you need to put in you application to connect to the database. It will also create the readme ADO_NET 2_0 Driver for InterBase XE Installation and Usage Instructions.htm file. IMPORTANT NOTE: the DB connection examples in this help htm file do not work 100% of the time. See my code example below for the solution.

No ODBC connection necessary. The list of the files to be included in your .NET project and to be copied local are:

  • Borland.Data.AdoDbxClient.dll
  • Borland.Data.DbxCommonDriver.dll
  • Borland.Data.DBXInterBaseDriver.dll
  • Borland.Delphi.dll
  • Borland.VclDbRtl.dll
  • Borland.VclRtl.dll
  • dbxadapter.dll (x86 or x64 version)
  • dbxint.dll (x86 or x64 version)
  • gds32.dll (from the interbase DB install)
  • interbase.msg (from the interbase DB install)

I found two connection strings that worked. To connect use one of two connection string:

connectionstring1 = "DriverName=Interbase;Database=" + database + ";User_Name=" + userid + ";Password=" + password;
connectionstring1 = connectionstring1 + ";SQLDialect=3;MetaDataAssemblyLoader=Borland.Data.TDBXInterbaseMetaDataCommandFactory,Borland.Data.DbxReadOnlyMetaData,Version=11.0.5000.0,Culture=neutral,";
connectionstring1 = connectionstring1 + "PublicKeyToken=91d62ebb5b0d1b1b;GetDriverFunc=getSQLDriverINTERBASE;LibraryName=dbxint30.dll;VendorLib=GDS32.DLL";

connectionstring2 = “User_Name="+userid+";Password="+password+";Database="+database+";ServerType=0;Charset=NONE;LibraryName=.\\dbxint.dll;VendorLib=GDS32.DLL;GetDriverFunc=getSQLDriverINTERBASE;SQLDialect=3";


GlobalObjects.dbconn = (TAdoDbxConnection)TAdoDbxInterBaseProviderFactory.Instance.CreateConnection();

GlobalObjects.database = databasepath;
GlobalObjects.dbconn.ConnectionString = connectionstring1;  //or connectionstring2
GlobalObjects.dbconn.Open();

The rest is like the example I gave previously.

Like I mentioned, this worked on Server 2012 and Windows 8.1 machines with only Interbase installed.