Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-05

PostgreSQL database connection error

13 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

peng

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"
4, I think should now be able to connect to database, so I put the value of the "Connected" from False to True, however, appeared error dialog:

------------------------------------------------------ error?
PQConnection1 : Connection to database failed (PostgreSQL: missing "=" after "select" in connection info string )

OK
------------------------------------------------------

I tested for a long time, including the Lazarus of 0.925 and zero 6.6.2rc, but have failed again and again, help!

??'?????'? http://pengtu.net/ooo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080529/7ba6e724/attachment.html

Reply by email

Damien Gerard
to Michael Van Canneyt: Params should be empty; this is not to enter a SQL statement. To execute a query, drop a…

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

Show quoted text 73 lines
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 "Intelligence is 10 million rules." -- Douglas Lenat

Reply by email

Michael Van Canneyt
to peng: Hellow everyone: I encountered an error when Postgresql in connection with Lazarus, as…
peng wrote 21 lines
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).

Michael.

Reply by email

peng
to Michael Van Canneyt

Thank you, Michael, in accordance with your recommendations, has been successfully connected! However, some new problems, form In Chinese characters appear garbled. Details are as follows:

1, Lazarus new form, from 'sqldb' tab, add the three essential components, set up a number of attributes.
2, from 'Data Access' tab, add a component: TDataSource, set attributes DataSet.
3, from the 'Data Controls' tab, add a component: TDBGrid, set attributes DataSource.

In this way, the editorial in the state of Lazarus, I can see TDBGird change from a blank into the full data. However, in the form of Chinese data garbled, even in the running after this. In an earlier time, I have tried to connect SQLite database, edit state is garbled, but in normal operation after RUN it. These two databases are UTF8 encoding, it appears to be a big problem. I am very eager to see the Chinese in the data.

UTF8 or ANSI, give me a recommendation? Thank you!

2008/5/29 Michael Van Canneyt :

Show quoted text 13 lines
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).
Michael.
??'?????'? http://pengtu.net/ooo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080529/58754bba/attachment.html

Reply by email

Michael Van Canneyt
to peng
peng wrote 17 lines
Thank you, Michael, in accordance with your recommendations, has been successfully connected! However, some new problems, form In Chinese characters appear garbled. Details are as follows: 1, Lazarus new form, from 'sqldb' tab, add the three essential components, set up a number of attributes. 2, from 'Data Access' tab, add a component: TDataSource, set attributes DataSet. 3, from the 'Data Controls' tab, add a component: TDBGrid, set attributes DataSource. In this way, the editorial in the state of Lazarus, I can see TDBGird change from a blank into the full data. However, in the form of Chinese data garbled, even in the running after this. In an earlier time, I have tried to connect SQLite database, edit state is garbled, but in normal operation after RUN it. These two databases are UTF8 encoding, it appears to be a big problem. I am very eager to see the Chinese in the data.

Hm.

I am not sure how to do this. I don't know how UTF-8 encoding works in Lazarus. Someone of the Lazarus team will have to answer this part of your question...

Michael.

Show quoted text 27 lines
UTF8 or ANSI, give me a recommendation? Thank you! 2008/5/29 Michael Van Canneyt : > 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). > Michael. > -- ??'?????'? http://pengtu.net/ooo

Reply by email

Mattias Gaertner
to peng: Thank you, Michael, in accordance with your recommendations, has been successfully…
Show quoted text 20 lines
Thank you, Michael, in accordance with your recommendations, has been successfully connected! However, some new problems, form In Chinese characters appear garbled. Details are as follows: 1, Lazarus new form, from 'sqldb' tab, add the three essential components, set up a number of attributes. 2, from 'Data Access' tab, add a component: TDataSource, set attributes DataSet. 3, from the 'Data Controls' tab, add a component: TDBGrid, set attributes DataSource. In this way, the editorial in the state of Lazarus, I can see TDBGird change from a blank into the full data. However, in the form of Chinese data garbled, even in the running after this. In an earlier time, I have tried to connect SQLite database, edit state is garbled, but in normal operation after RUN it. These two databases are UTF8 encoding, it appears to be a big problem. I am very eager to see the Chinese in the data. UTF8 or ANSI, give me a recommendation? Thank you!

I would say UTF-8, but I didn't tried chinese. Did you try the current lazarus from svn or daily snapshot?

http://wiki.lazarus.freepascal.org/LCL_Unicode_Support

Mattias

Reply by email

peng
to Mattias Gaertner

I will to try new snapshot version, however, whether there are other ways?

According to PostgreSQL users told me that in the P client set transcoding, for example:SET CLIENT_ENCODING TO 'GBK' .
The GBK is better able to show that the Chinese encoding, but, which position this SQL statement to add in ? I tried to add SQL attributes in TSQLQuery components, such as:

set client_encoding to 'gbk'
Select * from xiang

However, Lazarus report errors:
------------------------------
error:
Operation cannot be performed on an active dataset OK
------------------------------

If I make the database active attribute to false, then it can no longer be a True.

2008/5/29 Mattias Gaertner : > I would say UTF-8, but I didn't tried chinese. Did you try the current > lazarus from svn or daily snapshot? > > http://wiki.lazarus.freepascal.org/LCL_Unicode_Support > Mattias > -- ??'?????'? http://pengtu.net/ooo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080530/1279a36c/attachment.html

Reply by email

Joost van der Sluis
to peng

Op vrijdag 30-05-2008 om 04:43 uur [tijdzone +0800], schreef peng:

Show quoted text 8 lines
According to PostgreSQL users told me that in the P client set transcoding, for example:SET CLIENT_ENCODING TO 'GBK' . The GBK is better able to show that the Chinese encoding, but, which position this SQL statement to add in ? I tried to add SQL attributes in TSQLQuery components, such as: set client_encoding to 'gbk' Select * from xiang
Show quoted text 8 lines
However, Lazarus report errors: ------------------------------ error: Operation cannot be performed on an active dataset OK ------------------------------ If I make the database active attribute to false, then it can no longer be a True.

You should first set the client_encoding with
'TSQLConnection.ExecuteDirect('set client_encoding to ''gbk'');' Then you can open your query. (Note that you can only change the sql-statement of an query when it's closed)

Joost.

Reply by email

peng
to Joost van der Sluis

Thanks for your answer, but I do not know how to set up TSQLConnection.ExecuteDirect (......).
TSQLConnnection components in the election, I can not find ExecuteDirect attributes. Can give me concrete steps ? I am still a novice Lazarus, thank you!

2008/5/30 Joost van der Sluis : > You should first set the client_encoding with > 'TSQLConnection.ExecuteDirect('set client_encoding to ''gbk'');' > Then you can open your query. (Note that you can only change the > sql-statement of an query when it's closed) > Joost. > -- ??'?????'? http://pengtu.net/ooo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080530/f42b97c5/attachment.html

Reply by email

peng
to peng

Look ScreenPrint.

2008/5/30 peng :

Show quoted text 15 lines
Thanks for your answer, but I do not know how to set up TSQLConnection.ExecuteDirect (......). TSQLConnnection components in the election, I can not find ExecuteDirect attributes. Can give me concrete steps ? I am still a novice Lazarus, thank you! -- 2008/5/30 Joost van der Sluis : > You should first set the client_encoding with > 'TSQLConnection.ExecuteDirect('set client_encoding to ''gbk'');' > Then you can open your query. (Note that you can only change the > sql-statement of an query when it's closed) > Joost. >
??'?????'? http://pengtu.net/ooo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080531/3ce449af/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: Lazarus-Psql-encoding-err.png Type: image/png Size: 13998 bytes Desc: not available Url : http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080531/3ce449af/attachment-0001.png

Reply by email

peng
to peng

Is not what I am doing wrong ?

2008/5/31 peng :

Show quoted text 11 lines
Look ScreenPrint. 2008/5/30 peng : Thanks for your answer, but I do not know how to set up > TSQLConnection.ExecuteDirect (......). > TSQLConnnection components in the election, I can not find ExecuteDirect > attributes. Can give me concrete steps ? I am still a novice Lazarus, thank > you! >
??'?????'? http://pengtu.net/ooo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080531/9ce635f0/attachment.html

Reply by email

Vincent Snijders
to peng: Look ScreenPrint. 2008/5/30 peng : ??'?????'? http://pengtu.net/ooo -------------- next…
peng wrote
Look ScreenPrint.

Next time, please paste source code: that is easier to copy.

remvoe the line procedure TSQLConnection.ExecuteDirect ...

after the begin a line later add
  PQConnection1.ExecuteDirect('set client_encoding to ''gbk'');

Vincent

Show quoted text 18 lines
2008/5/30 peng < <mailto:>>: Thanks for your answer, but I do not know how to set up TSQLConnection.ExecuteDirect (......). TSQLConnnection components in the election, I can not find ExecuteDirect attributes. Can give me concrete steps ? I am still a novice Lazarus, thank you! -- 2008/5/30 Joost van der Sluis < <mailto:>>: You should first set the client_encoding with 'TSQLConnection.ExecuteDirect('set client_encoding to ''gbk'');' Then you can open your query. (Note that you can only change the sql-statement of an query when it's closed) Joost.

Reply by email

peng
to Vincent Snijders

oh, I see.
Can not experiment successful, perhaps I should first learn grammar. In addition, I try - dWindowsUnicodeSupport parameters compiled Lazarus, in DBGrid component, the right to directly see that the Chinese characters. Although there are some problems, I believe it will solve.

I do not quite fluent in English, no matter what, thank you!

2008/6/1 Vincent Snijders :

Show quoted text 8 lines
Next time, please paste source code: that is easier to copy. remvoe the line procedure TSQLConnection.ExecuteDirect ... after the begin a line later add PQConnection1.ExecuteDirect('set client_encoding to ''gbk''); Vincent

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080605/fb00b84c/attachment.html

Reply by email