SQL1159 Initialization error with DB2 .NET Data Pr

2019-05-29 05:08发布

I am trying to open a connection to DB2 in console application. It works fine. when I use the same code in a service, hosted in IIS it throws an error for DB2. Following is the error details. Am I missing some permissions in IIS ?

dll :IBM.data.DB2.dll

Code :

DB2Connection db2Connection = new DB2Connection(connectionString);
DB2Command cmdSelectUsrNameAndPassword = new DB2Command(querySelectUsernameAndPassword, db2Connection);
cmdSelectUsrNameAndPassword.Connection.Open();

Throws :

SQL1159 Initialization error with DB2 .NET Data Provider, reason code 10, tokens 0.0.0, 9.7.3

If I try a DSN with ODBC in console it works, but same throws another error in IIS.

OdbcConnection DbConnection = new OdbcConnection(DSNName);
DbConnection.Open();

Throws :

ASP.NET V4.0 does not have the authority to perform the requested command or operation.

标签: asp.net iis db2
5条回答
我欲成王,谁敢阻挡
2楼-- · 2019-05-29 05:16

While installing IBM data server client you did not uncheck the option to enable operating system security.

So you have to add the user(s), that need to use DB2 client dll, to DB2USERS group as it states in the final step of installation.

If you want IIS application pool identity use: "IIS AppPool\DefaultAppPool". Add that user to DB2USERS group. DefaultAppPool-> your application pool identity name

查看更多
SAY GOODBYE
3楼-- · 2019-05-29 05:24

Have a look at IBM support doc below which outlines why it happens and what the message means http://www-01.ibm.com/support/docview.wss?uid=swg21413731. It helped me, adding to the DB2USERS group allowed our app to work and is probably better than running as Network Service.

查看更多
戒情不戒烟
4楼-- · 2019-05-29 05:27

I had the same problem with an application running from IIS Express. Tried running Visual Studio as administrator and problem solved. Versions: DB2 Client Version 10.5, Visual Studio 2015.

查看更多
Summer. ? 凉城
5楼-- · 2019-05-29 05:28

guess it has something to do with App pool identity. I set the app pool identity as "Network service" and gave full permission to "Network Service" on "IBM.Data.DB.dll" in C:\Program Files\IBM\SQLLIB\BIN\netf20_32\ Worked neat.

查看更多
女痞
6楼-- · 2019-05-29 05:34

I encountered a very similar error message on one of my projects:

SQL1159 Initialization error with DB2 .NET Data Provider, reason code 10, tokens 0.0.0, 10.1.5

Having tried all of the solutions listed above and on the IBM documentation site, it ultimately ended up just being the case that the DB2 Connect installer needed to be run as administrator, rather than as a user account. Uninstalling it and reinstalling it as administrator resolved the problem.

Running the installer as administrator also unlocked options such as the ability to turn off extended security which had previously not been presented.

查看更多
登录 后发表回答