Commandline connection to MSSQL on portable HeidiSQL

Marc posted 5 years ago in HeidiSQL portable
Hi guys,

i've tried to connect to an local (also tried to connect to on hosted) mssql server by passing the connectionproperties with the commandline, but heidi given me every time an error ("unknown mysql server host").

my connection string was:
-host=localhost\MYINSTANCE -user=sa -password=sa12345 -d=TEST -D=testDatabase

can you help me please ?
PS: tried with version
ansgar posted 5 years ago
Command line options are MySQL specific yet. But you can pass a session name. Let's say you have named your MSSQL session "Microsoft" or "SQL server", then these command lines should work:
heidisql.exe -d=Microsoft
heidisql.exe -d="Microsoft"
heidisql.exe -d="SQL server"

But don't leave away the .exe suffix. I just found out that the command line parser expects that. A bug to fix for me.
Marc posted 5 years ago
Hi ansgar,

my problem is, that the login credentials change from time to time and i would like to get heidi connected as easy as possible (so i have the new credentials, but i wouldnt store it every time and safe it) ... so the command line sounds like a nice option to do this stuff programatically ... but it seems, that atm the cmd is only working with mysql ?

hm no prob, i've started to port your pw encryption from delphi to c# (already done this) and create a little "portable_settings.txt" with an small .net application. finished result: i click on "connect" on my .net app, it creates the settings.txt in %temp%, starts heidi with this settings.txt and immediately deletes the settings.txt =)

btw: wie ich grad sehe kommst du selbst aus D, daher ists leichter so zu schreiben, aber im sinne von anderen forums-usern, die vllt. mitlesen und vor der gleichen problematik stehen lasse ich den obrigen text mal auf englisch :D
ansgar posted 5 years ago
I thing I'm going to add a "nettype" parameter, which can be used to pass a number of supported protocols (mysql=0, mssql tcp/ip=4, etc.). Just like they appear in the session managers "Network type" dropdown.
ansgar posted 5 years ago
Done in r4868. Now supported:
heidisql.exe -n=0 (MySQL tcp/ip)
heidisql.exe -n=3 (MSSQL named pipe)
heidisql.exe -n=4 (MSSQL tcp/ip)
heidisql.exe -n=8 (PostgreSQL)
Marc posted 5 years ago
thx a lot =)
works like charm!
Marc posted 5 years ago
btw, if you (or someone else) need some c# port of the encrypt:

private static String HeidiPwEncrypt(String pass)
string result = string.Empty;
Random rnd = new Random();

int salt = rnd.Next(0, 9) + 1;

foreach (int nr in pass.Select(t => t + salt))
string h = (nr > 255 ? nr - 255 : nr).ToString("X");
if (h.Length == 1) h = "0" + h;
result += h;
return result + salt;

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