Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lower Case database name is throwing an error on connection object. #210

Open
sasictas opened this issue Mar 10, 2021 · 1 comment
Open

Comments

@sasictas
Copy link

Connection string is built dynamically by taking user input on server name, database name, port, user name and password.

database name was in lower case and Open method on connection string throws an error.

I go back and change database name to upper case and hit connect button. At this point new connection string is populated based on user input and open command still gives error. The only way to get this work is exit application, restart and provide database name in upper case first time.

Please see the error message images in following url links.

https://drive.google.com/file/d/1dbrWFrfFIDBEJ_xKV3Hf5uMMOWMOHmMQ/view?usp=sharing

https://drive.google.com/file/d/1dbrWFrfFIDBEJ_xKV3Hf5uMMOWMOHmMQ/view?usp=sharing

To Reproduce
private string sybaseDBConnString()
{
string sybConnStr = "Data Source = @SrvR; database = @db; Port = @PORT; UID = @usn; PWD = @tlm;";

        sybConnStr = sybConnStr.Replace("@srvr", tbDBserver.Text.Trim());
        sybConnStr = sybConnStr.Replace("@db", tbDBname.Text.Trim());
        sybConnStr = sybConnStr.Replace("@port", tbDBport.Text.Trim());
        sybConnStr = sybConnStr.Replace("@usn", tbDBuname.Text.Trim());
        sybConnStr = sybConnStr.Replace("@tlm", tbDBtalam.Text.Trim());

        return sybConnStr;
    }

string dbConnStr = sybaseDBConnString();
AseConnection conn = new AseConnection(dbConnStr);
try
{
conn.Open();
var clms = conn.Query(mipsClmsSqlStr);
conn.Close();
MessageBox.Show("success");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + Environment.NewLine + Environment.NewLine + ex.StackTrace);
}
finally
{
conn.Dispose();

        }

Expected behavior
when i rebuild the connection string with upper case, create a new connection object, i should connect with no issues.

Environment

  • .NET Framework/Core version 4.7.2
  • AdoNetCore.AseClient nuget package version 0.19.2

Additional context
Add any other context about the problem here.

@jeroen-vh
Copy link

This will probably work if you disable connection pooling in your connection string:

string sybConnStr = "Data Source = @SrvR; database = @db; Port = @PORT; UID = @usn; PWD = @tlm; pooling='false';";

It looks like the ConnectionPoolManager ignores casing so the same connection is reused if you change the databasename from lowercase to uppercase with connectionpooling enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants