Board index » delphi » TQuery produces 'access violation'

TQuery produces 'access violation'

Hi,

I'm having this strange behaviour on my Database project. I've been
trying to track it down for long time, but at no success. Maybe I can
get a hint on this:

Im, accessing a Database using an BDE - ODBC connection. Now, this is
quite a complex application so I will only refer to the context where
the crash happens.

-There is a global TConnection Component which is used by all the
 Components.

-There is a local A : TQuery which will perform an operation on
 a live DataSet. Ths Component was created at design time.

....

A.Close;
A.SQL.Clear;
A.SQL.Add(select A_NUMBER, A_STRING, A_MEMO from A_TABLE where A_ID =
10);
A.Open;
A.First;
A.Append; //or A.Edit;
A.FieldByName('A_NUMBER').AsInteger := 10;
A.FieldByName('A_STRING').AsInteger := 'aaa';
A.FieldByName('A_NUMBER').Assign(AStringList);
A.Post;
A.Close;   //Here happens the the access violation

The first time I perform this operation I get an acces violation.
When I call this function again everything works fine!

So I ask myself: If there are any parameters missing, why should the
operation work on the second attempt?

Any ideas?

Thanks in advance

 

Re:TQuery produces 'access violation'


Well, today I came about this piece of code:

begin

AList := TStringList.Create;

AQuery.Open; //select TEXT1 from TABLE1
AQuery.First;
AQuery.Append; //or Edit
AQuery.FieldByName('TEXT1').Assign(AList); //AList assigned, but empty
AQuery.Post; //Crash!!
AQuery.Close;

end;

Exception: ODBC Error : String data right truncation!

So, ist this a bug?
Should I have known it?

Other Threads