Le May 28, 2008 à 9:38 PM, Michael Van Canneyt a écrit :

>
>
> On Thu, 29 May 2008, peng wrote:
>
>> Hellow everyone:
>>
>> I  encountered an error when Postgresql in connection with Lazarus,  
>> as
>> follows.
>>
>> My environment is window xp Chinese , the installation of the  
>> Lazzrus 0.924
>> and  Postgresql 8.3 . Lazarus can run and compile unit, the  
>> Postgresql can
>> use pgadmin III visit. I created an data table "xiang" in the default
>> database "postgres", including Chinese and English characters,  
>> Encoded by
>> the uft8. and then copy the libpq.dll and other files to the  
>> Windows system
>> directory. Next steps are:
>>
>> 1, Lazarus creat a new form;
>> 2, placing a TPQconnection components to the form;
>> 3, setting the component attributes. For example:
>> Hostname = localhost
>> DatabaseName = postgres
>> UserName = postgres
>> Password = 1234
>> Name = PQConnection1
>> Params = "select * from xiang"
>
> Params should be empty; this is not to enter a SQL statement.
>
> To execute a query, drop a TSQLQuery on the form (SQLQuery1, for  
> example),
> and set
>  SQLQuery1.SQL.Text:='select * from xiang';
>
> and connect it to the connection component:
>
>  SQLQuery1.Database:=PQConnection1;
>
> Then drop a TSQLTransaction (SQLTransaction1) on the form.
> Connect it to the database as well:
>  SQLTransaction1.Database:=PQConnection1;
>
> and finally connect the SQLQuery1 to the transaction:
>
>  SQLQuery1.Transaction:=SQLTransaction1;
>
> Now set
>
>  PQConnection1.Connected:=True;
>
> and then
>
>  SQLQuery1.Active:=True;
>
> And then your query will be executed.
>
> To use SQLDB, you need always 3 components:
>
> 1. A TSQLConnection component.
>   This controls the connection to the database.
>
> 2. A TSQLTransaction component.
>   This controls the transaction in which a query is executed.
>   It is connected to the TSQLConnection.
>
> 3. A TSQLQuery component.
>   This executes queries.
>   It is connected to the TSQLConnection component (the database)
>   and the TSQLTransaction (the transaction context).


May be this text should be added somewhere in the wiki ?



--
Damien Gerard
[EMAIL PROTECTED]

"Intelligence is 10 million rules."
    -- Douglas Lenat






_______________________________________________
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to