Recent

Author Topic: Who knows how work TODBCConnection ?  (Read 3572 times)

JeanChriChri

  • Newbie
  • Posts: 2
Who knows how work TODBCConnection ?
« on: May 22, 2008, 03:59:49 pm »
Hi all,

There is nothing all over the web, no example !  :(

Who could give a simple-but-good example of ODBC (unit odbcconn)

Thank you.

JeanChriChri

  • Newbie
  • Posts: 2
RE: Who knows how work TODBCConnection ?
« Reply #1 on: May 22, 2008, 05:37:26 pm »
At last, I found ONE example.



program Test;

uses
    Classes, odbcconn, sqldb;

var
   aODBCConn : TODBCConnection;
   aODBCTransaction : TSQLTransaction;
   aSQLQuery : TSQLQuery;

begin

     aODBCConn := TODBCConnection.Create(Nil);
     with aODBCConn do
     begin
          DatabaseName := 'SomeDataBase';
          HostName := 'MSSQLServer';
          Driver := 'SQL Server';
          Password := 'pass';
          Username := 'sa';
          Open;
     end;

     aODBCTransaction := TSQLTransaction.Create(nil);
     aODBCTransaction.DataBase := aODBCConn;

     aSQLQuery := TSQLQuery.Create(nil);
     with aSQLQuery do
     begin
          DataBase := aODBCConn;
          Transaction := aODBCTransaction;
          SQL.Clear;
          SQL.Add('SELECT * FROM claim WHERE inc=12');
          Open;
     end;

     aSQLQuery.Close;
     aSQLQuery.Free;

end.

 

TinyPortal © 2005-2018