I need to know is there any feature of connecting to DB2 database from .net in .Net framework 4.0
EDIT:- I like to know if there is any DB2 provider
Yep, the family of IBM.Data.DB2 drivers (collectively found in IBM.Data.DB2.dll, I believe) should work just fine with .NET, providing you install the drivers on your development machine.
Additionally, I was able to get it to work successfully with VS2010Beta and EF4Beta2, despite the lack of Visual Studio Add-ins for VS2010 (as of this date.) If the drivers are installed on your machine already, you just need to add an entry for it in the machine.config file for .NET 4.0's clr.
EDIT: Sample machine.config markup follows. Originally, the config file just had the single SQL server DB Provider Factory entry. Assuming you have IBM.Data.DB2 installed on your machine, you can do what I did and simply open up your 2.0's machine.config file and copy/paste the entries for DB2. Full disclosure, I honestly don't know if all 4 are required, but a clean install of 9.7fp1 inserted all four entries in my 2.0 machine.config, so I went ahead and copied them all over to 4.0 machine.config. Copy/paste, save the file, and restart visual studio 2010 and you should be able to reference the provider in your EDMX with the information in the storage model definition:
<edmx:StorageModels>
<Schema xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl" Namespace="BlahModel.Store" Alias="Self" Provider="IBM.Data.DB2" ProviderManifestToken="IDS/UNIX64, 11.50.0000">
Note that I'm interested in connecting to an informix database, hence the ProviderManifestToken value. However, I don't think that's required verbatim.
The snippet from my 4.0 machine.config:
<system.data>
<DbProviderFactories>
<add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
<add name="IBM DB2 .NET Data Provider" invariant="IBM.Data.DB2" description="IBM DB2 Data Provider for .NET Framework 2.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
<add name="IBM Informix .NET Data Provider" invariant="IBM.Data.Informix" description="IBM Informix Data Provider for .NET Framework 2.0" type="IBM.Data.Informix.IfxFactory, IBM.Data.Informix, Version=9.0.0.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
<add name="IBM DB2 .NET Data Provider 9.7.1" invariant="IBM.Data.DB2.9.7.1" description="IBM DB2 Data Provider 9.7.1 for .NET Framework 2.0" type="IBM.Data.DB2.DB2Factory, IBM.Data.DB2.9.7.1, Version=9.7.1.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
<add name="IBM Informix .NET Data Provider 9.7.1" invariant="IBM.Data.Informix.9.7.1" description="IBM Informix Data Provider 9.7.1 for .NET Framework 2.0" type="IBM.Data.Informix.IfxFactory, IBM.Data.Informix.9.7.1, Version=9.7.1.2, Culture=neutral, PublicKeyToken=7c307b91aa13d208" />
</DbProviderFactories>
</system.data>
EDIT 2: IBM's latest DB2 drivers -- v9.7fp4 -- have greatly improved .NET 4.0 and VS2010 Add-In support. Its installation will automatically handle the 4.0 machine.config DbProviderFactories entries. If you previously manually edited entries, as described above, you'll want to comment out/delete them as part of your v9.7fp3 (and earlier) uninstalls.
What do you mean? You want something specific to .NET 4.0 or you want to know that whether we can connect with DB2 using .NET Framework or not.
If later is the case, yes you can. OleDBConnection class(which is available in .NET 2.0 and .NET 3.5 as well) has a property ConnectionString in which you set the provider's details. You simply have to give the provider's connection string for your DB2 provider and you should be OK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With