Skip to content
Permalink
Browse files

Do not pass TCP port to MS SQL if named instance in host name present…

…. Fixes issue #2767.
  • Loading branch information...
ansgarbecker committed Mar 13, 2012
1 parent 9b7a1a8 commit 1c76c2ecc0ed7d87cda822228802bedf48a143fe
Showing with 7 additions and 2 deletions.
  1. +6 −1 source/connections.pas
  2. +1 −1 source/dbconnection.pas
@@ -433,7 +433,10 @@ function Tconnform.CurrentParams: TConnectionParameters;
Result.Password := editPassword.Text;
Result.LoginPrompt := chkLoginPrompt.Checked;
Result.WindowsAuth := chkWindowsAuth.Checked;
Result.Port := updownPort.Position;
if updownPort.Enabled then
Result.Port := updownPort.Position
else
Result.Port := 0;
Result.AllDatabasesStr := comboDatabases.Text;
Result.SSHHost := editSSHHost.Text;
Result.SSHPort := MakeInt(editSSHPort.Text);
@@ -830,6 +833,8 @@ procedure Tconnform.ValidateControls;
lblPassword.Enabled := lblUsername.Enabled;
editPassword.Enabled := lblUsername.Enabled;
lblPort.Enabled := Params.NetType in [ntMySQL_TCPIP, ntMySQL_SSHtunnel, ntMSSQL_TCPIP];
if (Params.NetType = ntMSSQL_TCPIP) and (Pos('\', editHost.Text) > 0) then
lblPort.Enabled := False; // Named instance without port
editPort.Enabled := lblPort.Enabled;
updownPort.Enabled := lblPort.Enabled;
tabSSLoptions.TabVisible := Params.NetType = ntMySQL_TCPIP;
@@ -1027,7 +1027,7 @@ procedure TAdoDBConnection.SetActive(Value: Boolean);
ntMSSQL_RPC: NetLib := 'DBMSRPCN';
end;
DataSource := Parameters.Hostname;
if Parameters.NetType = ntMSSQL_TCPIP then
if (Parameters.NetType = ntMSSQL_TCPIP) and (Parameters.Port <> 0) then
DataSource := DataSource + ','+IntToStr(Parameters.Port);
FAdoHandle.ConnectionString := 'Provider=SQLOLEDB;'+
'Password='+Parameters.Password+';'+

0 comments on commit 1c76c2e

Please sign in to comment.
You can’t perform that action at this time.