0

I am not new in software developement but I am new to developement with Lazarus IDE. Currently I am working on a project that uses a SQL Server database. It is not difficult to connect to the database and executing SQL queries.

But I have the problem that disconnecting from the SQL Server database causes errors and I don't know why.

In a short listing, I connect to the database, check if is connected and after that I try to disconnect from database:

   Ret: String;
   DBConnExp: TSQLConnector;
   SQLTrans: TSQLTransaction;
begin
   DBConnExp := TSQLConnector.Create(nil);
   DBConnExp.ConnectorType := 'MSSQLServer';
   DBConnExp.LoginPrompt := False;
   DBConnExp.DatabaseName := 'myDatabase';
   DBConnExp.HostName := 'SERVER\SQLEXPRESS';
   DBConnExp.UserName := 'username';
   DBConnExp.Password := 'password';
   DBConnExp.Open;
   DBConnExp.Connected := True;
   SQLTrans := TSQLTransaction.Create(DBConnExp);
   DBConnExp.Transaction := SQLTrans;

   IF DBConnExp.Connected then
      Ret := 'connected'
   else
      Ret := 'not connected';

   SQLTrans.CloseDataSets;
   SQLTrans.Free;
   DBConnExp.Connected := False;

Just here during debugging the execution gets stuck and I have no idea why:

   IF DBConnExp.Connected then
      Ret := 'connected'
   else
      Ret := 'not connected';

I use the latest compiled dlls' from freeTDS

Is there anybody who can help me to find out what is the problem?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

0 Answers0