I am trying to connect to an Informix database and need to add this reference to my project:
using IBM.Data.Informix;
What package in package manager console do I need to be able to use this library?
Thanks in advance!
To connect to an Informix database from .NET you have to options:
The Informix .NET Provider
The IBM Data Server .NET Provider
Have a look at this tech note which describes both .NET provider:
https://www.ibm.com/developerworks/data/library/techarticle/dm-1007dsnetids/
Both will work with Informix. The first one is the 'native' .NET provider included with CSDK (CSDK or ClientSDK is the product that includes all the Informix drivers (ODBC/OLEDB/.NET) etc.
At the moment the only way to get the drivers installed is with a stand alone package (Informix CSDK). There are some plans to get them in NuGet, so you would be able to get the drivers directly from the Visual Studio package manager without anything to install.
The second option, 'IBM Data Server .Net Provider' is included in the 'IBM Data Server' which is an 'common' set of drivers from IBM. It will allow you to connect to either DB2 or Informix (through a DRDA connection)
You can get the IBM Data Server Driver Package from the IBM website, or download the .NET drivers (and required libraries) directly from NuGet:
https://www.nuget.org/packages/IBM.Data.DB.Provider/
PM> Install-Package IBM.Data.DB.Provider
The .NET assembly class is called 'IBM.Data.DB2.dll' There used to be a 'replacement' dll named the same as the Informix CSDK one (IBM.Data.Informix.dll) but is now deprecated. Even with that name ;) it is fully supported against Informix databases.
There are some differences between the .NET providers (e.g. connection string) so if you are going to use the 'DB2' one, I suggest to check the documentation at:
https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.swg.im.dbclient.adonet.doc/doc/c0024472.html
There is also a new beta .NET provider for the new '.NET Core' supporting both Windows and Linux platforms. If you are going to develop for .NET Core, this is the one you want
https://www.nuget.org/packages/IBM.Data.DB2.Core/1.0.0.100
PM> Install-Package IBM.Data.DB2.Core
Related
With Visual Studio 2008 I'm trying to connect to an Oracle database using Oracle Provider to OLE DB (the only Oracle driver available in dropdown), and I'm having issues with it. So I'm trying to add other drivers to that VS2008 "Connection Manager" dropdown. Unfortunately, I only see the ones in this screenshot
How can I add other drivers to this dropdown? When I create an ODBC driver, I see several other Oracle drivers to choose from that I don't see in the VS2008 dropdown.
You installed more than one Oracle Client, this is always a bad idea. Usually there is no reason to install more than one Oracle Client, i.e. one each for 32-bit and 64-bit.
For OLE DB you cannot install more than one driver (per architecture), see Installation Considerations for Oracle Database Client:
You can install all Oracle components in multiple Oracle homes on the
same computer. However, some components can only support one active
instance at a time. This means that the current (latest) installation
renders the previous one inactive. These components are:
Oracle Administration Assistant for Windows
Oracle Provider for OLE DB
This is a limitation in COM. So, you cannot add other providers, at least no other Oracle Provider for OLE DB
You could use the Microsoft OLE DB Provider for Oracle (MSDAORA), however this has been deprecated for ages and it is really not recommended to use it.
Instead of OLE DB you could also use ODBC or use the Oracle Data Provider for .NET, you can download and install it from here: 32-bit Oracle Data Access Components (ODAC)
As far as I know Visual Studio 2008 supports only .NET Framework only up to version 3.5, thus you would have to use the Oracle Data Provider for .NET 2.0, version 4 will not work.
Maybe this list provides an overview for you: How to connect to Oracle 11 database from . net
If you like to get a list of all OLE DB providers which are installed on your machine, check this one: How to check the version of oracle provider for ole-db. OraOLEDB.Oracle provider
Ok - I have VS 2012 and VS 2013 installed on a 32-bit developer machine running Windows 7 Enterprise and am attempting to connect to an Oracle 9 database. I can install version 12.1.0.24 without a problem, and I can connect to most databases using ODP.NET Managed and Unmanaged drivers through Server Data Connections tool, etc. Problem is that I also have to build applications that connect to legacy Oracle DB Server instances, and really need an older version of the VS Tools and ODP.NET / ODAC, ie 11.2.3.20. This seemingly installs correctly, but when you try to build a new data connection, the default Data Provider is ".NET Framework Data Provider for Oracle" There is an option for "Oracle Data Provider for .NET", but there is seemingly no way to specify a tnsnames.ora location, and the only option available in the "Data Source Name" combo is "(Local Database)."
Furthermore no option for picking Managed or Unmanaged for the Provider is available. Can somebody please tell me the proper thing to do to get this to work? Are there machine-wide configurations I have to make manually, that the installer for 12.1.0.24 does automatically?
Usually there is no need to install more than one Oracle Client (resp. one each for 32-bit and 64-bit). You can connect to older database with 12.1 client (for Managed Driver the Database must be 10.2 or newer).
Most likely you messed up your Oracle installation, remove them all and install one version from scratch.
In order to make you application independent from installed Oracle Client open *.csproj, resp. *.vbproj file and edit reference to ODP.NET like this:
<Reference Include="Oracle.DataAccess">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
Attributes like Version=... or processorArchitecture=... are not required. Your application will load the correct Oracle.DataAccess.dll depending on selected architecture and target .NET framework (provided that it is installed properly)
"Oracle.DataAccess" and "Oracle.ManagedDataAccess" are different assemblies, so you cannot use them seamless - unless you use DbProviderFactory and such stuff.
I have just started to create an ASP.NET Core Web API Project. I am not much aware of "ASP.NET Core .NET Standard Library".
I am creating this application using Visual Studio 2017 RC and in the application, I have taken a project of type Class Library (.NET Standard) at repository layer.
Following is the screenshot for the same:
Now from repository Layer I want to connect to the database. I have created a variable
IDbConnection con;
Now I am trying to add reference of System.Data but I am unable to add any reference because when I am opening the add reference window then I am getting the following message:
No Framework assemblies were found on the machine.
How can I connect to database using .NET Core Class Library(.NET Standard)?
.NET Standard Class libraries don't work by directly referencing a DLL, because with .NET Core there is no guarantee the framework will be installed on the system and .NET Core applications can also run as self-contained applications which ship the framework libraries with the application and do not require a runtime to be installed before.
You have to use the NuGet package manager (or project.json or *.csproj in VS2017) to add dependencies. For SQLServer you need to add the System.Data.SqlClient package (link) if you want to directly communicate with the Database (i.e. w/o an ORM).
Above answer (Tseng) may have been valid in 2016 and .NET Standard 1.4, but in the meantime, Microsoft did remove some showstoppers, allowing access to SQL Server from a .NET Standard 2.1 library. Mind the old System.Data.SqlClient will not link, so you (really!) have to refer EF6 via NuGet and change some using.
Create a .NET Standard Class library and put version on 2.1
Install Entity framework (this contains the lower level libs)
In using, refer to System.Data and to Microsoft.Data
Using are:
using System.Data
using Microsoft.Data.SqlClient
Now, "legacy" classes like DataSet, SqlConnection and SqlClient will become available.
It is not completely compatible (yet) There are some things that are not available in .NET standard 2.1, such as enumerating available SQL servers on the LAN. This was done with SqlDataSourceEnumerator which is a class in System.Data I cannot locate in Microsoft.Data.
NOTE: I tested successfully with a .Net Core 3.1 console application. A Standard lib configured as above can be called from .NET Core and connect to the database without issues. You cannot use a .NET Framework caller.
I'm working on an android Application using Xamarin and Visual Studio 2015. Our data is in AS400 systems. I'm trying to connect to the AS400 via DB2 using the iSeries. I'm referencing the IBM.Data.DB2.iSeries.dll as I use this dll for my other web applications that work fine with DB2. I get the following error as soon as I try to create a new connection object: The type initializer for "IBM.Data.DB2.iSeries.iDB2tracing" threw an exception. When I check the android device monitor is like it can't access any of the classes from the IBM.Data.DB2.iSeries.dll. Is unable to use this dll. Are there some kid of permissions that I am missing? I'm also doing no linking so it includes all my dlls.
Thank you!
AS/400 and iSeries are both names for an old IBM midrange system that is now called IBM i on Power. IBM i is the operating system, Power Systems is the hardware. The specific dialect of DB2 that runs under IBM i is DB2 for i. IBM.Data.DB2.iSeries.dll is the DB2 for i .NET provider for Windows. If you want to access DB2 for i from Android, the best thing might be a JDBC driver. You can get that at http://jt400.sourceforge.net/
I have a very simple application on .Net that connect to Oracle using ODP (was compiled with Oracle.DataAccess dll 10.2).
I want to check "connection prerequisite" (application will be able to connect to DB) before installing this aplication on other computers?
How can I check that ODP.NET version 10.2 or higher is installed on target host (registry check is not enopugh)?
I know that I can check ODP entries in registry - but this will not check Oracle Client and compatibility between client and ODP.
Also, if ODP was installed by ODAC XCopy installation - registry may be not updated by new ODP entry.
And - if I am installing on the computer, DB was installed on, Oracle Client can be not installed separately.
And one more issue: When I tried to run "test connection" method from installation, that use referenced dll on machine, that has only ODAC (with ODP) 11, - "Oracle.DataAccess.Client.OracleException The provider is not compatible with the version of Oracle client at Oracle.DataAccess.Client.OracleInit.Initialize()
at Oracle.DataAccess.Client.OracleConnection..cctor()" error message was thrown (policies for both ODAC 10.2 and 11 are exists in GAC (assembly), pointing to Oracle.DataAccess 11 from ODP 2x bin).
So, How and which components can I check to ensure appropriate versions of ODP and Oracle Client were installed and application will be connected?
Thank you in advance!
You can use the DataProvider Factory Classes from .Net. This will show all data providers that are available to your current .Net installation / process. I have a blog post here on how to do it. I put it in place to prevent our users from using versions of Oracle that were not supported with .Net 4.0.
http://blog.tsells.com/2011/05/12/oracle-11g-release-2-and-net-framework-4-0-and-version-checking/
I recently found out that Oracle is not supporting the .net 4.0 framework with any version of the Oracle Provider for .Net prior to 11.2.0.2. (See Oracle Data Provider for .NET (ODP) Supported Configurations [ID 726240.1] from oracle support for more details).
Since the prior versions work (10.2, 11.1, 11.2.0.1) then I needed a way to prevent end users from using the wrong version. I searched the net and could not find any one who was able to do this so I did some digging. After some testing I came up with the following code.
System.Data.Common.DbProviderFactory factory =
System.Data.Common.DbProviderFactories.GetFactory("Oracle.DataAccess.Client");
if (factory == null)
return false;
Type t = factory.GetType();
int majorversion = t.Assembly.GetName().Version.Major;
// Do not allow any major versions less than 4
if (majorversion < 4)
return false;
This code will use the same data provider that is registered with the .net framework version you are using. This ensures you are not out of sink in your environment and allows you to inspect the version of the dll installed. For this example – I am just checking that ODP is 4.0 or higher (first release of odp for .net 4).