Skip to content
New issue

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

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

Already on GitHub? # to your account

When trying to change default database it fails because connection is not open #1

Closed
JamesHorsley opened this issue Feb 26, 2021 · 1 comment

Comments

@JamesHorsley
Copy link

In this below the call to cn.ChangeDatabase fails because the connection is not yet open - it needs moving to after the cn.Open()

try
                {
                    if (!database.Equals("master", StringComparison.InvariantCultureIgnoreCase))
                    {
                        cn.ChangeDatabase(database);
                    }

                    var sqlBatch = string.Empty;
                    var cmd = new SqlCommand(string.Empty, cn);
                    cn.Open();
@rabryst
Copy link
Contributor

rabryst commented Jun 8, 2021

Hi James! Feel free to submit a pull request and I'll commit this code. Thanks for the issue, and sorry for the delayed response.

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

No branches or pull requests

2 participants