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

Ignores Database set in connection string #4

Open
PhilMakower opened this issue Feb 26, 2024 · 0 comments
Open

Ignores Database set in connection string #4

PhilMakower opened this issue Feb 26, 2024 · 0 comments

Comments

@PhilMakower
Copy link

I am using this tool to try to migrate Contour 3 forms on Umbraco v7.15.10 to UmbracoForms v4.4.9 (to start with)
It takes no notice of the database set in the connection string I provide.
Adding code to log the DB_NAME() value shows that the main Umbraco database is being used!
So the table "UFForms" does not exist, for example.
I added code to pull out the "initial catalogue" from the connection string, and the call "USE " SQL.
Now DB_NAME() is as expected.

// https://stackoverflow.com/questions/10550541/how-to-get-database-name-from-connection-string-using-sqlconnectionstringbuilder
System.Data.SqlClient.SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder(connString);
string Database = builder.InitialCatalog;

string cmd = @"USE "+Database; // set current database
sql.ExecuteNonQuery(cmd);

/*string */cmd = @"SELECT DB_NAME()"; // name of current database
string db = sql.ExecuteScalar<string>(cmd);
LogHelper.Info<MigrationService>("ISqlHelper DB_NAME() returns =\"" + db + "\"");
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

1 participant