Commandline connection to MSSQL on portable HeidiSQL

[expired user #8499]'s profile image [expired user #8499] posted 9 years ago in HeidiSQL portable Permalink
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 9.0.0.4865
ansgar's profile image ansgar posted 9 years ago Permalink
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.
[expired user #8499]'s profile image [expired user #8499] posted 9 years ago Permalink
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's profile image ansgar posted 9 years ago Permalink
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.
Code modification/commit from ansgar.becker, 9 years ago, revision 9.1.0.4868
Support new command line parameter "n", or "nettype", which takes an integer, representing the protocol number (0=mysql tcpip, ...). See http://www.heidisql.com/forum.php?t=16891
ansgar's profile image ansgar posted 9 years ago Permalink
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)
[expired user #8499]'s profile image [expired user #8499] posted 9 years ago Permalink
thx a lot =)
works like charm!
[expired user #8499]'s profile image [expired user #8499] posted 9 years ago Permalink
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.