DB2 connection

  • Thread starter Thread starter =?iso-8859-1?Q?Vicente_Garc=EDa?=
  • Start date Start date
?

=?iso-8859-1?Q?Vicente_Garc=EDa?=

Hi all,

I would like to connect my ASP .NET 2.0 site to a DB2 database but I don't know how I could do that and I don't find a correct provider :(

For instance if I want to connect my site with Access I do the folling in my code file:
Imports System.Data.OleDb
...
Dim DBConnection As OleDbConnection
Dim DBCommand As OleDbCommand
Dim DBReader As OleDbDataReader
Dim SQLString As String
DBConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/basedatos.mdb")
DBConnection.Open()
SQLString = "SELECT * FROM Nombres"
DBCommand = New OleDbCommand(SQLString, DBConnection)
DBReader = DBCommand.ExecuteReader()
DBReader.Close()
Could anyone please tell my how to connect my application to DB2, pleaseeee

Thanks in advance,
Vicente
 
Hello Vicente,

Before establishing a connection between ASP.NET 2.0 and Access you
have to consider few steps. Which are

-> Your database must be added in System DSN
-> Use System.Data.Odbc to connect to access database.

You can use OleDb provider to establish a connection between .NET & Sql
Server.

Try this & do let me know in any kind of difficulties you face.

Regards,
Mohsin Rizvi
 
Hi,

I established a connection to my DB2 database with System.Data.Odbc and the following connection string: "DSN=CC;UID=myuser;PWD=mypass" but then the source code and the data base must be in the same computer. I am wondering if I can put my code in one computer and the data base in another one? How is the connection string?

Thanks in advance!!
Vicente.
 
Hello Vicente!

Thanx for putting up the problem again.

I'm pasting an example connection string for access database. I hope
this will help you.

->Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\tradefamily-websiteroot\GoogleGroups\App_Data\db2.mdb;Persist
Security Info=True

Path to the data source should be absolute physical path.

I hope this will help you & do let me know in any case.

Regards,
Mohsin Rizvi
 
Many thanks Mohsin!

First of all, apologies for my poor English :(
Yes, I executed the application with a access database and it worked perfectly but I needed the connection string to a DB2 database...Just now I find out the method:
connectionString="Driver={IBM DB2 ODBC DRIVER};Database=MY_DATABASE;Hostname=THE_IP;Port=THE_PORT;Protocol=TCPIP;Uid=THE_USER;Pwd=THE_PASS;"

This works fine as well :))
Thanks for the help and the interest

Regards!
Vicente

"Mohsin Rizvi" <[email protected]> escribió en el mensaje Hello Vicente!

Thanx for putting up the problem again.

I'm pasting an example connection string for access database. I hope
this will help you.

->Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\tradefamily-websiteroot\GoogleGroups\App_Data\db2.mdb;Persist
Security Info=True

Path to the data source should be absolute physical path.

I hope this will help you & do let me know in any case.

Regards,
Mohsin Rizvi
 
Back
Top