Re: Update a Value From TEdit - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: Update a Value From TEdit
Date
Msg-id 461FCB33.3060308@iol.ie
Whole thread Raw
In response to Update a Value From TEdit  (Bob Pawley <rjpawley@shaw.ca>)
Responses Re: Update a Value From TEdit  (Raymond O'Donnell <rod@iol.ie>)
List pgsql-general
On 13/04/2007 19:05, Bob Pawley wrote:

> I am attempting to update a table using a value that
> is displayed on a TEdit component. I am getting an
> access violation error.

Hi Bob,

An access violation error means that some part of your code is trying to
access memory that it shouldn't. It most likely means that you're trying
to use a component that hasn't yet been created, so it's a bug in your
code rather than a problem with PostgreSQL.

>        PSQLQuery1.Close;{close the query}
>       //assign new SQL expression Monitor
>       PSQLQuery1.SQL.Clear;
>       PSQLQuery1.SQL.Add ('Update P_ID.Loops');
>       PSQLQuery1.SQL.Add ('Set IDW_Loop_ID = + LoopNumberEdit');
>       PSQLQuery1.SQL.Add ('Where P_ID.Loops.Loop_Name = :Loop_Name');
>       PSQLQuery1.ParamByName('LoopNumberEdit').Value := Edit1.Text;
>       PSQLQuery1.Execsql;

How do you create PSQLQuery1? - Did you drop it on the form at
design-time, or have you created it on-the-fly in your code? If the
latter, then that's probably your problem - have you called
PSQLQuery1.Create() somewhere before the code above executes?

However, if PSQLQuery1 was created at design time, then the problem lies
elsewhere. Look for some component which you've declared, but whose
constructor you haven't invoked.

BTW, from the code above it seems you're passing in an integer value to
the query; I prefer to use ParamByName().AsInteger as an extra layer of
safety, to ensure that an integer acyually does get passed in.

Ray.

---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
---------------------------------------------------------------


pgsql-general by date:

Previous
From: "Kynn Jones"
Date:
Subject: OT: schema-sketching software
Next
From: Raymond O'Donnell
Date:
Subject: Re: Update a Value From TEdit