microsoft / mssql-scripter

Repository for the new SQL cross-platform command line tools
Other
736 stars 142 forks source link

Cannot connect to SQL Server when password includes semicolon #234

Open poyrazus opened 4 years ago

poyrazus commented 4 years ago

When the password includes semicolon character, then I get error.

Scripting request: e31b1716-762c-44b3-9447-c3f8ee5a050e encountered error: Error parsing ScriptingParams.ConnectionString property. Error details: System.ArgumentException: Error parsing ScriptingParams.ConnectionString property. ---> System.ArgumentException: Format of the initialization string does not conform to specification starting at index 94. at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary2 parsetable, String connectionString, Boolean buildChain, Dictionary2 synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary`2 synonyms, Boolean useOdbcRules) at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value) at System.Data.SqlClient.SqlConnectionStringBuilder..ctor(String connectionString) at

It took me a while to find the exact cause. I've spend a lot time with different combinations of --server and --connection-string options. Then I've tried against another database (with different user and password) and then realized that it's because of ';' character in password.

Just installed mssql-scripter today, so it should be the latest version. Version: 1.0.0a23

Here is one of the very commands I've tried mssql-scripter -S 127.0.0.1 -d database_name -U user_name

Charles-Gagnon commented 4 years ago

Have you tried escaping the semicolon in the password with a \?

e.g. if your password is my;password then it would be my\;password

Semicolon is used as a delimiter in the connection string so if that's a part of the password it'd need to be escaped.

poyrazus commented 4 years ago

Hi Charles,

After your comment, I've tried that as well. But it didn't work. Same error. In addition, one thing I saw in my trials is that if semicolon is at the end of the password, it gives "Login failed" error (escaped or unescaped doesn't matter).

In my case, I have created another database user and made my backup with that (luckily I have those privileges).

dylan-azucena commented 3 years ago

FWIW I was hitting this error as well (with semicolons in password). Adding double quotes around the password worked for me.

araisantai commented 1 year ago

FWIW I was hitting this error as well (with semicolons in password). Adding double quotes around the password worked for me.

did you add it in the backend query, because i face similiar problem