Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Updating Memo field crashes DBISAM Server
Wed, Nov 9 2016 7:52 PMPermanent Link

Graham Mylne

Hi

I have a scenario where I have an TMemo field on screen and it has over 1300 lines of text. Each line im just entering the number 1. Doesnt matter what it is, looks similar to this:

1
1
1
1
1
1

i then run an sql to feed this into the memo field in the database and it crashes the database server with an access violation. The source for DBISAM server seems to stop at FreeNextExpressionToken.

The data saved doesnt seem to matter its just the number of lines apparently in a memo, once you get past around 1300 lines its crashes.

Any ideas?



Attachments: LargeQueryTest.zip
Wed, Nov 9 2016 9:34 PMPermanent Link

Graham Mylne

Also its not DB aware its using TDBISAMQuery and feeding the memo text straight into the query and running.
Wed, Nov 9 2016 11:03 PMPermanent Link

Graham Mylne

So the project seems to work, but if you copy the text from this text file into the application and run it crashes the server, something about the way the string is handled/terminated, trying to search for any hidden characters and trying different file encoding types but no difference, very strange.



Attachments: 1.txt
Thu, Nov 10 2016 2:46 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Graham


I have a vague memory of something like this. In my case I think it was in ElevateDB rather than DBISAM so probably nothing useful but here goes.

Memory says it was down to having a single line that was essentially making the parser throw up. The cure in my case was simply to split the statement onto multiple lines. I'll have a hunt through the archive and see if I can find it but don't hold your breath because I can't remember anything specific to search on Frown


Another, and unrelated, small point - you don't need '11'+#13+''+#10 simply '11'+#13 will suffice


Roy Lambert
Thu, Nov 10 2016 3:06 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Graham


I found the post I was looking for and the problem was

<<With a bit more research I think its EDBManager objecting to the fact that the binary is spread over several rows in the SQL editor window. AT least it worked when I got rid of enough data to allow me to put it all on a single row.>>

As I was typing a silly thought went through my head - TMemo used to be restricted to 32k (I think it was) this could mean that after 1300 lines you exceed the capacity and the data is being cropped. Try using a TRichEdit with PlainText set to True.


Roy Lambert
Thu, Nov 10 2016 4:19 AMPermanent Link

Matthew Jones

Graham Mylne wrote:

> i then run an sql to feed this into the memo field in the database

I've not opened the project, but are you saying you are making a SQL statement with the contents of the memo in the SQL too? If so, err, don't! You should be using a parameter for feeding the data in. I imagine from the error you mention that the parser is trying to be clever with the text, and getting lost. It wouldn't have such problems with a parameter, and you don't worry about conversion.

If you are using a parameter, then it sounds like a problem indeed.

--

Matthew Jones
Thu, Nov 10 2016 1:43 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Graham,

The SQL parser in DBISAM uses recursion, so you're blowing out the stack when you feed it such a long concatenated string.

You should build the string in code and feed it as a parameter to the query, and that will solve the problem.

Tim Young
Elevate Software
www.elevatesoft.com
Sun, Nov 13 2016 1:39 AMPermanent Link

Graham Mylne

Ok ill try updating the field using a parameter and let everyone know. Thanks for the help.
Sun, Nov 13 2016 2:19 AMPermanent Link

Graham Mylne

Ok that did it, using a parameter seemed to work fine, thanks for the help.
Image