error in connecting when password contains semicolon

jenda86 posted 2 years ago in General

I am having problems when I try to connect to MSSQL server when password contains semicolon (i.e. abds;abc ) - HeidiSQL doesnt even try to connect and outputs error message: SQL Error(0) - Invalid argument of connection string (I translated this message from my native language, I hope it is right, I couldn't get it in English).

Since the server isn't under my management, but client's, it is not possible to change the pass, thus I cannot connect at all.

You might look into it.
Max posted 2 years ago
Hey jenda86

i got the same problem when i used heidi sql and the ssl tunnel. The problem is you use an " in your passwort and when plink.exe tried to connect to the server it looks like

plink.exe -P 22 -L 3307: -pw "yourPW" root@host.com

so when you have a double quotes in your password plink.exe dont send all the password it will send only to the second double quote.

Example: your"pw

plink.exe will send onli your because the syntax is

plink.exe -P 22 -L 3307: -pw "your"PW" root@host.com

try to change the password on the mysql host or open plink.exe manually... like this http://www.heidisql.com/forum.php?t=6561
jenda86 posted 2 years ago

Thanks for reply.
However that does not describe my problem.
I am not using SSH tunnel and not MYSQL at all. And I cannot change the password of MSSQL password, since it is server of our client who uses it elsewhere.

And when I try to connect with password where is not semicolon (;) the application at least try to connect. With semicolon it doesnt even try to connect and gives me that error msg.
ansgar posted 2 years ago
Passwords are not yet quoted in HeidiSQL's connection string, but they need to be if they contain a semicolon: http://forums.asp.net/t/1957484.aspx?Passwords+ending+with+semi+colon+as+the+terminal+element+in+connection+strings+

I'll change that but I need to test that first.
ansgar posted 2 years ago
Done in r4701. Please test and report back.

jenda86 posted 2 years ago
Hello ansgar.

Your fix helped and now Heidi connects without any issues.
Thanks for very quick fix and also for the great app!

kalvaro posted 2 years ago

// Quote password, just in case there is a semicolon or a double quote in it.
// See http://forums.asp.net/t/1957484.aspx?Passwords+ending+with+semi+colon+as+the+terminal+element+in+connection+strings+
if Pos('"', Parameters.Password) > 0 then
QuotedPassword := ''''+Parameters.Password+''''
QuotedPassword := '"'+Parameters.Password+'"';

What happens if the password has double quotes and single quotes?
ansgar posted 2 years ago
Yes that's what came into my mind as well. No clue. Microsoft does not say a word about that in their documentation.
ansgar posted 2 years ago
Oh, there is a way:

msdoc wrote: If the value contains both single-quote and double-quote characters, the quotation mark character used to enclose the value must be doubled every time it occurs within the value.

Quite much effort for just an escaping issue...

Please login to leave a reply, or register at first.