Parameterized Queries with PostGreSql - Violation Access

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
rc
Posts: 11
Joined: Thu 24 Dec 2009 13:46
Location: France

Parameterized Queries with PostGreSql - Violation Access

Post by rc » Mon 29 Mar 2010 09:15

I work with Unidac components v3.00 under Delphi 2010. The following parameterized request works fine under Oracle and Firebird, but raises an violation access error with PostGreSql, when I open the Query. Is there any obvious reason ?

Sql Text :

Code: Select all

Select U.ID_UTILISATEUR, U.NOM, U.MOT_PASSE
from UTILISATEUR U, UTILISATEUR_COMMUNE UC
where U.ID_UTILISATEUR = UC.ID_UTILISATEUR
and upper(NOM) = upper(:NOM)
and MOT_PASSE = :MOT_PASSE
Calling code :

Code: Select all

  Query.Params[0].AsString := EditUtilisateur.Text;
  Query.Params[1].AsString := MotPasse;
  Query.Open;
Thank you for your help !

NB : This code woks perfectly with BDE and OBDC connection.

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Mon 29 Mar 2010 14:26

Unfortunately, the information you have provided is not enough to reproduce your issue. We need additional information. Please send us the DDL script for creating the tables that are used in your query. Also please tell us where the error occurred: on parameter assignment or on query execution.

rc
Posts: 11
Joined: Thu 24 Dec 2009 13:46
Location: France

Post by rc » Mon 29 Mar 2010 14:58

I am sorry :oops:, the problem is not where I figured it to be. There is nothing wrong with the query.

The problem is that I am working with a connection dynamically configured at runtime, and apparently, assigning the provider name at runtime does not initialize correctly specific options, as it does at design time. So I can connect to the database, but opening a query raises an error.

So my question is now : Is there a simple way I can give end users the possiblity to type un the parameters of their connections to their databases (it can be Oracle, Firebird, Sql Server or PostGreSQL local or distant databases), and then save their parameters.

I worked out a solution that works fine with Firebird and Oracle, but fails with PostGreSql.

Thank you very much in advance for your help !

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Tue 30 Mar 2010 09:41

To reproduce your issue we need to know the list of specific options that you assigned for PostgreSQL.

rc
Posts: 11
Joined: Thu 24 Dec 2009 13:46
Location: France

Post by rc » Tue 30 Mar 2010 12:49

I don't specify any specific option, the only parameters I specify, beside ProviderName, are server, database, username and password. I presumed my problem was coming from PostgreSql's specific options, for my application is working fine with Firebird, Oracle and Sql Server. But maybe my guess was false. All I can say with certainty is that the process that works with other DBMS doesn't work with PostGreSql.

Here is the way I do things :
Users can configure their connection parameters in a separate application. Then that application saves the configured connection in a Delphi component resource file.
As the main application starts, it opens the ressource file, reads the ressource via ReadComponentRes, and assigns it to its main connection before connecting to the database.

All this works fine with other DBMS. Even with PostGreSql I get a message confirming that my connection is connected, but when I want to open a TUniTable or TUniQuery, I get an access violation.
And if I close the application, even without opening any dataset, I get an Invalid Pointer Operation at the time TUniconnection is being freed.

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Thu 01 Apr 2010 08:56

To reproduce your issue we need to get your forms with UniConnection and UniQueries. Also we need to get Delphi resource files that have been generated by your second application for the PostgreSQL connection.

Post Reply