🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.pascal
1 messages
1 total messages Started by MrDudek Fri, 18 Feb 2011 00:42
[FPC] PostgreSQL i TSQLQuery.Open
#89782
Author: MrDudek
Date: Fri, 18 Feb 2011 00:42
71 lines
1302 bytes
Witam

Ju¿ nie mam pojêcia gdzie szukaæ. Poni¿szy kod kompilowany fpc na
linuxie

<code>
{$mode objfpc}{$H+}

program test;

uses Classes, SysUtils, postgres, DB, SQLdb, PQConnection;

var
  C: TPQConnection;
  T: TSQLTransaction;
  Q: TSQLQuery;
begin
  C := TPQConnection.Create(nil);
  T := TSQLTransaction.Create(nil);
  Q := TSQLQuery.Create(nil);
  try
    try
      C.Hostname := 'localhost';
      C.DatabaseName := 'dbname';
      C.UserName := 'uname';
      C.Password := 'password';
      C.Transaction := T;

      T.Database := C;
      C.Open;
      writeln('C.Open');

      Q.Database := C;
      Q.Transaction := T;
      Q.SQL.Text := 'SELECT id FROM tbrand';

      Q.Open;
      writeln('Q.Open');
    except
      on E: Exception do writeln(E.Message);
    end;
  finally
    writeln('Finally 1');
    Q.Free;
    writeln('Finally 2');
    T.Free;
    C.Close;
  end;
end.
</code>

generuje nastêpuj±ce wyniki.

C.Open
Access violation
Finally 1
Finally 2
An unhandled exception occurred at $00147BF0 :
EAccessViolation : Access violation
  $00147BF0
  $080AC986
  $080A7E66
  $0016C917

Dla ciekawo¶ci, Q.ExecSQL dzia³a poprawnie.
Bêdê wdziêczy je¶li kto¶ podsunie mi jakie¶ sensowne pomys³y.

--
Pozdrawiam
Andrzej Kosmala

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads