1 (edited by teco049 2017-02-06 10:23:54)

Topic: SOLVED: Problem with Testapplication

Hi,
I have a problem with a little test application where I am testing some basic functions I need in further projects.

Project is attached.

What it should to:
- You enter some values in a table and a hash value is created as a kind of "seal" for these values.
- Later you edit some entries, but the hash will not be updated (as a proof that the record has been changed.
- Later you delete some records. So you have some holes in the IDs.

What are the problem:
- Accessing a fild as "asboolean" creates an error.
- When I click on "Check/Compare" the Application hangs.

Any idea why this happens and is this handling possible?

Tested with MyVisualDatabase 3.1

Re: SOLVED: Problem with Testapplication

Hello.


You project have not attached to the post. Please attach your project like zip file without exe and dlls files.

Dmitry.

Re: SOLVED: Problem with Testapplication

Sorry, Here it is

Post's attachments

Attachment icon Test-Projekt2.zip 9.52 kb, 501 downloads since 2017-02-03 

Re: SOLVED: Problem with Testapplication

Hello teco049,


I had a look at your application (very interesting) and found two things :


About your application hanging :
You create a TDataSet with :

sqlquery('select * from entries',evaluate);

This is fine


Then you tell the app to shuffle through all the results with

while not evaluate.Eof do

This is fine (Eof meaning End Of File, that is to say until the last record)


Then you free the TDataSet object with

evaluate.free;

This is fine, you don't need it anymore so destroy it to avoid memory leaks


But you forgot one step, you have to tell the app that it as to step to next recordset after each completed loop with

evaluate.Next;

your code should be like :

while not evaluate.Eof do
       begin
          checkmate := strtomd5(evaluate.fieldbyname('valueA').asstring + evaluate.fieldbyname('valueA').asstring);
          recordid := evaluate.fieldbyname('ID').asinteger;

          if (evaluate.fieldbyname('valueC').asstring <> checkmate) then
              begin
                 evaluate.fieldbyname('resultb').asstring := 'true';
              end
          else
              begin
                 evaluate.fieldbyname('resultB').asstring := 'false';
              end;
           evaluate.Next;
       end;
   evaluate.free;

Add that extra 'evaluate.Next' to your code and the application won't hang anymore.


Now, regarding this  and your boolean problem :

//evaluate.fieldbyname('result').asboolean := true;
evaluate.fieldbyname('resultb').asstring := 'true';

Boolean are recorder as Integer, so you could do this :

evaluate.fieldbyname('result').AsInteger := 1;

This being fixed, what are you trying to achieve with this TDataSet and comparison ? Do you wan't to display in your TableGrid wether the record has been modified or not ?
Because what your are doing right now is just changing in memory the value assigned to 'result' according to a comparison. You're not updating the database nor the TableGrid column displaying the result.


Tell me what you wan't to do and I'll try to help


Cheers



Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: SOLVED: Problem with Testapplication

Hello mathmathou,
Thanks for helping to find the step I have forgotten.

What I want is to update the database with the testresult.
I was hoping that changing the value would directly change the database too and not only the memory.

I was trying to access the "ID" of the record but this has not worked. Following a copy from the original try - with your correction - which was not working:

while not evaluate.Eof do
       begin
          checkmate := strtomd5(evaluate.fieldbyname('valueA').asstring + evaluate.fieldbyname('valueA').asstring);
          recordid := evaluate.fieldbyname('ID').asinteger;

          if (evaluate.fieldbyname('valueC').asstring <> checkmate) then
              begin
                 sqlexecute('update entries set resultB = 1 where id='+recordid);
              end
          else
              begin
                  sqlexecute('update entries set resultB = 0 where id='+recordid);
              end;
           evaluate.Next;
       end;
   evaluate.free;

- Errors are possible because I am at the moment not at work...

The "evaluate.fieldname('ID').asinteger" create an error message but not working result. Maybe something missing here or is it not possible to access the ID field this way?

Finally it should be a test system for checking database records if they have been modified outside the application with a Database Browser.

At the end it would be something like

checkmate := strtomd5(evaluate.fieldbyname('valueA').asstring + evaluate.fieldbyname('valueA').asstring + SecretWord);

Where "SecretWord : string" and stored inside the Application or Database as base64 encoded value.

Is there a Delphi Source about encryption (AES, Blowfish, Twofish, etc.) which can be included in MyVisualDatabase or is there any restriction because it comes from Russia? I would like to encrypt the SecretWord and some Fields more complicated to prevent some "weekend hackers" or "script kiddis" from changing record values.

Thank you.

Re: SOLVED: Problem with Testapplication

REPAIRD.

After fixing some typing errors everything is working as planned.

Thank you.

7 (edited by bemorhona-qt 2017-02-06 11:23:18)

Re: SOLVED: Problem with Testapplication

teco049 wrote:

REPAIRD.

After fixing some typing errors everything is working as planned.

Thank you.

Dear teco049!
Can you attach your project?

Re: SOLVED: Problem with Testapplication

Here we go.
Remember: It is ony a test application. For real usage there is a lot more of work needed. This way shows only how it could work but not how it could be safe (this is up to your imagination).

Post's attachments

Attachment icon Test-Projekt2.zip 8.8 kb, 522 downloads since 2017-02-06