[Lazarus] TMSSQLConnection how to specify the server port?

Bo Berglund bo.berglund at gmail.com
Wed Dec 27 17:32:38 CET 2017


On Wed, 27 Dec 2017 14:05:55 +0000, Graeme Geldenhuys via Lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>On 2017-12-27 13:29, Bo Berglund via Lazarus wrote:
>> But now I am back on a Windows 7 machine and here I don't have a clue
>> as to how one installs the FreeTDS library.
>> 
>> Any pointers to how it is done?
>
>
>You simply download the DLL and include it in the same directory as the 
>EXE of your application, or install it to a global location like 
>System32 directory.
>
>    ftp://ftp.freepascal.org/fpc/contrib/windows/
>

I have tested this and no matter which of the included dll files in
the zip I put into my project directory I always get the exception:

"... exception class 'EInOutError' with message
Can not load DB-lib client library "dblib.dll". Check your
installation."

Something must be amiss.
I have downloaded zipfiles 0.95 and 1.00

Both of them contain:
Win32:
  dblib_2000.dll
  dblib_2008.dll
  libiconv2.dll
Win64:
  dblib.dll
  dblib_2008.dll
  libiconv.dll

I have tried the only one with the correct name (in Win64), did not
work.
Then I renamed the Win32/dblib_2008.dll to dblib.dll, not working

Right now I am only at the very first step of the application, namely
where I connect to the server:

SVNA is a class where I intend to handle the audit database:
constructor TSvnAuditer.Create;
begin
  FConn := TMSSQLConnection.Create(nil);
  FQuery := TSQLQuery.Create(nil);
  FTrans := TSQLTransaction.Create(nil);
  FConn.Transaction := FTrans;
  FQuery.Transaction := FTrans;
  FQuery.DataBase := FConn;
end;


procedure TestDbConnection;
begin
  SVNA.Server := 'servername:1433';
  SVNA.Database := 'databasename';
  SVNA.User := 'username';
  SVNA.Passwd := 'password';
  if SVNA.OpenConnection then
  begin
    SVNA.CloseConnection;
  end;
end;

function TSvnAuditer.OpenConnection: boolean;
begin
  Result := false;
  if (FServer = '') or (FUser = '') or (FPasswd = '') or (FDatabase =
'') then
  begin
    FErrorMsg := 'At least one of Server, Database, User or Password
has not been set!';
    exit;
  end;

  if Connected then
    CloseConnection;

  FConn.HostName := FServer;
  FConn.UserName := FUser;
  FConn.Password := FPasswd;
  FConn.DatabaseName := FDatabase;
  FConn.Open;   <== Exception here! Not finding the dll!
  Result := Connected;
end;


-- 
Bo Berglund
Developer in Sweden



More information about the Lazarus mailing list