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
------------------------------