Original Message:
Sent: Mon March 06, 2023 02:32 AM
From: Roland Schock
Subject: setting currentSchema in connection string causes IBM.Data.DB2.Core.DB2Exception
Hi Silva,
the error message points to a completely different topic. What is the codepage setting on the client side? And what is the codepage setting on the server side?
Do you have in your code access to a result set structure called SQLCA? This can give you loads of details to the error above.
please have a look at https://www.ibm.com/docs/en/db2/11.5?topic=tables-sqlca-sql-communications-area
and SQLDA to get the information of the codepages used in this connection. Either on the client side or server side, there might be a codepage conversion table missing, leading to this error.
Cheers
------------------------------
Roland Schock
IBM Champion and IBM Gold Consultant
Original Message:
Sent: Sun March 05, 2023 08:43 AM
From: Siva Sankaran
Subject: setting currentSchema in connection string causes IBM.Data.DB2.Core.DB2Exception
In our .net core 3.1 app we are using NuGet Gallery | IBM.Data.DB2.Core 3.1.0.600 package for connecting with DB2 . We are unable to set schema in connection string and this leaves us to use schema name into the query. But it causes security violation issue from our security analysis tool as those query strings are concatenating. Even interpolated string raises the same security violation.
Either using ConnectionString Builder Object
DB2ConnectionStringBuilder dB2ConnectionStringBuilder = new DB2ConnectionStringBuilder(); dB2ConnectionStringBuilder.Server = "appDB.myorg.com:123"; dB2ConnectionStringBuilder.Database = "database"; dB2ConnectionStringBuilder.UserID = "user"; dB2ConnectionStringBuilder.Password = "***:D***"; dB2ConnectionStringBuilder.CurrentSchema = "MySchema";string connString = dB2ConnectionStringBuilder.ConnectionString;
Or using raw connection string
Server=appDB.myorg.com:1200;Database=database;UID=user;PWD=**:D***;CurrentSchema=MySchema;
Following code throws IBM.Data.DB2.Core.DB2Exception When connection. Open() invoked.
using DB2Connection MyDb2Connection = new DB2Connection(connString); MyDb2Connection.Open();
The error message is
ERROR [57017] [IBM] SQL0332N Character conversion from the source code page "" to the target code page "" is not supported. SQLSTATE=57017
The same issue here https://stackoverflow.com/a/66818035/449413
Please share a way to set schema dynamically , since we need different schema based on the environment
------------------------------
Siva Sankaran
------------------------------