|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
[C#] Connect to IBM DB2 databaseI'm working on a C# project and want to connect to a IBM DB2 database in order to retrieve a DataSet. I'm using the ODBC driver. The code is the following: ----------------------------------------------------------------------------------- .... OdbcConnection odbcConn = new OdbcConnection("Driver={IBM DB2 ODBC DRIVER};Server=localhost;DSN=TESTDB;UID=username;PWD=pwd;Protocol=TCPIP"); odbcConn.Open(); .... ----------------------------------------------------------------------------------- When I'm trying to open the connection I obtain the following message: "ERROR [08001] [IBM][CLI Driver] CLI0104E Connexion à la source de données impossible. SQLSTATE=08001 ERROR [IM006] [Microsoft][Gestionnaire de pilotes ODBC] Échec SQLSetConnectAttr du pilote" When I try to open the connection through the ODBC driver, I have no error, it's just with the C# application. If you have any idea, thanks to give me more information. G. Hello,
You need IBM DB2 connect or Microsoft's Host Integration Server to talk to mainframe from C#.NET. I've done a similar project using IBM DB2 connect for a leading retailer. Please check the following things: 1. IBM DB2 connect should be installed in the machine, where your C# Data Acess components (for DB2) lives 2. You should not be using OBDC Connection object. If you install IBM DB2 connect for .NET, you get DB2 Connects' API's for .NET. There you have DB2 connection, DB2Command and other related objects. With that you can play with Mainframe's DataAccess 3. The following is the code-snippet, i've used in my project DB2Connection cn = new DB2Connection( "Database=TEST;UserID=db2admin; Password=password;Server=IS500"); DB2Command cmd = new DB2Command("SELECT COUNT(*) FROM EMP01", cn); int count = Convert.ToInt32(cmd.ExecuteScalar()); 3. I'm not sure whether ODBC driver will workf fine with Mainframe's DB2. 4. It is bettter to use the driver provided by IBM (when you install DB2 connect) -- Show quoteThanks & Regards, Mark Nelson "Gandalf" wrote: > Hi, > > I'm working on a C# project and want to connect to a IBM DB2 database in > order to retrieve a DataSet. I'm using the ODBC driver. The code is the > following: > > ----------------------------------------------------------------------------------- > ... > OdbcConnection odbcConn = new OdbcConnection("Driver={IBM DB2 ODBC > DRIVER};Server=localhost;DSN=TESTDB;UID=username;PWD=pwd;Protocol=TCPIP"); > odbcConn.Open(); > ... > ----------------------------------------------------------------------------------- > > When I'm trying to open the connection I obtain the following message: > "ERROR [08001] [IBM][CLI Driver] CLI0104E Connexion à la source de données > impossible. SQLSTATE=08001 > ERROR [IM006] [Microsoft][Gestionnaire de pilotes ODBC] Échec > SQLSetConnectAttr du pilote" > > When I try to open the connection through the ODBC driver, I have no error, > it's just with the C# application. > > If you have any idea, thanks to give me more information. > > G. Hi,
Thanks for the inofmation. Later I downloaded the driver IBM.Data.DB2 from "Mono" and I tried what you recommended to me but I obtain the following message: "Impossible to load assembly IBM.Data.DB2 Version=1.0.0.0, Culture=neutral, PublicKeyToken=7c307b91aa13d208 Exception de HRESULT : 0x8013141A". I should perhaps use the specific driver from IBM ? However, I read that the Mono driver was also compatible. Thanks for more information. Show quote "Mark Nelson" wrote: > > Hello, > > You need IBM DB2 connect or Microsoft's Host Integration Server to talk to > mainframe from C#.NET. > > I've done a similar project using IBM DB2 connect for a leading retailer. > > Please check the following things: > 1. IBM DB2 connect should be installed in the machine, where your C# Data > Acess components (for DB2) lives > 2. You should not be using OBDC Connection object. If you install IBM DB2 > connect for .NET, you get DB2 Connects' API's for .NET. There you have DB2 > connection, DB2Command and other related objects. With that you can play with > Mainframe's DataAccess > > 3. The following is the code-snippet, i've used in my project > DB2Connection cn = new DB2Connection( > "Database=TEST;UserID=db2admin; Password=password;Server=IS500"); > DB2Command cmd = new DB2Command("SELECT COUNT(*) FROM EMP01", cn); > int count = Convert.ToInt32(cmd.ExecuteScalar()); > > 3. I'm not sure whether ODBC driver will workf fine with Mainframe's DB2. > 4. It is bettter to use the driver provided by IBM (when you install DB2 > connect) > > -- > Thanks & Regards, > Mark Nelson > > > "Gandalf" wrote: > > > Hi, > > > > I'm working on a C# project and want to connect to a IBM DB2 database in > > order to retrieve a DataSet. I'm using the ODBC driver. The code is the > > following: > > > > ----------------------------------------------------------------------------------- > > ... > > OdbcConnection odbcConn = new OdbcConnection("Driver={IBM DB2 ODBC > > DRIVER};Server=localhost;DSN=TESTDB;UID=username;PWD=pwd;Protocol=TCPIP"); > > odbcConn.Open(); > > ... > > ----------------------------------------------------------------------------------- > > > > When I'm trying to open the connection I obtain the following message: > > "ERROR [08001] [IBM][CLI Driver] CLI0104E Connexion à la source de données > > impossible. SQLSTATE=08001 > > ERROR [IM006] [Microsoft][Gestionnaire de pilotes ODBC] Échec > > SQLSetConnectAttr du pilote" > > > > When I try to open the connection through the ODBC driver, I have no error, > > it's just with the C# application. > > > > If you have any idea, thanks to give me more information. > > > > G. Gandalf,
I'm not sure that whether IBM DB2 driver alone will provide the DataAccess for Mainframe DB2. You need a full installation of DB2 Connect (licensed) software to accomplish this goal. If my reply was useful, please press "Yes" to "Was this post helpful to you?" This will acknowledge that i've answered your question -- Show quoteThanks & Regards, Mark Nelson "Gandalf" wrote: > Hi, > > Thanks for the inofmation. > Later I downloaded the driver IBM.Data.DB2 from "Mono" and I tried what you > recommended to me but I obtain the following message: > > "Impossible to load assembly IBM.Data.DB2 Version=1.0.0.0, Culture=neutral, > PublicKeyToken=7c307b91aa13d208 Exception de HRESULT : 0x8013141A". > > I should perhaps use the specific driver from IBM ? However, I read that the > Mono driver was also compatible. > > Thanks for more information. > > > "Mark Nelson" wrote: > > > > > Hello, > > > > You need IBM DB2 connect or Microsoft's Host Integration Server to talk to > > mainframe from C#.NET. > > > > I've done a similar project using IBM DB2 connect for a leading retailer. > > > > Please check the following things: > > 1. IBM DB2 connect should be installed in the machine, where your C# Data > > Acess components (for DB2) lives > > 2. You should not be using OBDC Connection object. If you install IBM DB2 > > connect for .NET, you get DB2 Connects' API's for .NET. There you have DB2 > > connection, DB2Command and other related objects. With that you can play with > > Mainframe's DataAccess > > > > 3. The following is the code-snippet, i've used in my project > > DB2Connection cn = new DB2Connection( > > "Database=TEST;UserID=db2admin; Password=password;Server=IS500"); > > DB2Command cmd = new DB2Command("SELECT COUNT(*) FROM EMP01", cn); > > int count = Convert.ToInt32(cmd.ExecuteScalar()); > > > > 3. I'm not sure whether ODBC driver will workf fine with Mainframe's DB2. > > 4. It is bettter to use the driver provided by IBM (when you install DB2 > > connect) > > > > -- > > Thanks & Regards, > > Mark Nelson > > > > > > "Gandalf" wrote: > > > > > Hi, > > > > > > I'm working on a C# project and want to connect to a IBM DB2 database in > > > order to retrieve a DataSet. I'm using the ODBC driver. The code is the > > > following: > > > > > > ----------------------------------------------------------------------------------- > > > ... > > > OdbcConnection odbcConn = new OdbcConnection("Driver={IBM DB2 ODBC > > > DRIVER};Server=localhost;DSN=TESTDB;UID=username;PWD=pwd;Protocol=TCPIP"); > > > odbcConn.Open(); > > > ... > > > ----------------------------------------------------------------------------------- > > > > > > When I'm trying to open the connection I obtain the following message: > > > "ERROR [08001] [IBM][CLI Driver] CLI0104E Connexion à la source de données > > > impossible. SQLSTATE=08001 > > > ERROR [IM006] [Microsoft][Gestionnaire de pilotes ODBC] Échec > > > SQLSetConnectAttr du pilote" > > > > > > When I try to open the connection through the ODBC driver, I have no error, > > > it's just with the C# application. > > > > > > If you have any idea, thanks to give me more information. > > > > > > G. |
|||||||||||||||||||||||