Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Access Violation in Delphi Code


Hello all,
I am going insane by this error that I cannot fix. I've spent a few weeks googling and trying various changes to the code. I EVEN tried debugging the goddamn thing in OLLY Debugger! But to no avail.

Summary of My Program:-
Connects to an MS-SQL database and extracts signatures & images of customers and dumps them to a .BMP file using the TDBImage control.

How I did it:-
Created a TQuery & a TDataSource object. The TDBImage uses the datasource and the datasource in turn uses the query. After the image is loaded into the TDBImage I use TDBImage.Picture.SaveToFile(file_name) to save to disk.
And the query uses a database from BDE Administrator of course :)


After the user clicks a 'Begin' button, I run a loop for all the data in the database and with every loop iteration, I execute an SQL statement using Query1.SQL[0]='Select Image from ImageTable where SeqNo=' + inToStr(i), where 'i' is the loop variable of course.

In this way all the 15000 records of the database were supposed to be processed. But I get an 'Access Violation' error and an 'Invalid Pointer' error. Sometimes just one, sometimes both and sometimes my 'try' 'except' doesn't even catch the exception and the program exits silently.

I tried everything I could. I tried fastmemshare, machine level debugging, googled 'Access Violations' & 'Invalid Pointers', studied about Delphi's (@str-8) string reference counts etc etc but I am very sad to say that I could not come up with a fix.

I have attached my program (very small just 8Kb) for reference.

If anyone could help me out, I would be very very grateful. Thanks in advance to anyone who can help me :)


Prashu

Comments

  • SimonPrg123SimonPrg123 Member Posts: 64
    :
    : Hello all,
    : I am going insane by this error that I cannot fix. I've spent a few
    : weeks googling and trying various changes to the code. I EVEN tried
    : debugging the goddamn thing in OLLY Debugger! But to no avail.
    :
    : Summary of My Program:-
    : Connects to an MS-SQL database and extracts signatures & images of
    : customers and dumps them to a .BMP file using the TDBImage control.
    :
    : How I did it:-
    : Created a TQuery & a TDataSource object. The TDBImage uses the
    : datasource and the datasource in turn uses the query. After the
    : image is loaded into the TDBImage I use
    : TDBImage.Picture.SaveToFile(file_name) to save to disk.
    : And the query uses a database from BDE Administrator of course :)
    :
    :
    : After the user clicks a 'Begin' button, I run a loop for all the
    : data in the database and with every loop iteration, I execute an SQL
    : statement using Query1.SQL[0]='Select Image from ImageTable where
    : SeqNo=' + inToStr(i), where 'i' is the loop variable of course.
    :
    : In this way all the 15000 records of the database were supposed to
    : be processed. But I get an 'Access Violation' error and an 'Invalid
    : Pointer' error. Sometimes just one, sometimes both and sometimes my
    : 'try' 'except' doesn't even catch the exception and the program
    : exits silently.
    :
    : I tried everything I could. I tried fastmemshare, machine level
    : debugging, googled 'Access Violations' & 'Invalid Pointers', studied
    : about Delphi's (@str-8) string reference counts etc etc but I am
    : very sad to say that I could not come up with a fix.
    :
    : I have attached my program (very small just 8Kb) for reference.
    :
    : If anyone could help me out, I would be very very grateful. Thanks
    : in advance to anyone who can help me :)
    :
    :
    : Prashu
    :
    Hi Prashu

    Tell me do i understand correct you want to take images out of the database and save them to the computer?

    I downloaded your program code to see whether or not i can help you but without the db i can do anything...

    if i understand you correctly then you don't need a DBTimage a normal Timage will do the trick, timage has less stuff and memory running and using than the DBTimage... let me know... if i did not understood your problem correctly maybe just state exactly what your objective with the program is and i might be able to give you a short cut of somekind....


    good luck

  • blackmysticblackmystic Member Posts: 3
    : Tell me do i understand correct you want to take images out of the
    : database and save them to the computer?
    :
    : I downloaded your program code to see whether or not i can help you
    : but without the db i can do anything...
    :
    : if i understand you correctly then you don't need a DBTimage a
    : normal Timage will do the trick, timage has less stuff and memory
    : running and using than the DBTimage... let me know... if i did not
    : understood your problem correctly maybe just state exactly what your
    : objective with the program is and i might be able to give you a
    : short cut of somekind....

    Thank you for the reply. You have understood perfectly. If you can provide me with a shortcut I would be more than happy. Also if you give me ur email id, I could probably send you a small database(around 2 Mb)so that you can test it.
  • SimonPrg123SimonPrg123 Member Posts: 64
    : : Tell me do i understand correct you want to take images out of the
    : : database and save them to the computer?
    : :
    : : I downloaded your program code to see whether or not i can help you
    : : but without the db i can do anything...
    : :
    : : if i understand you correctly then you don't need a DBTimage a
    : : normal Timage will do the trick, timage has less stuff and memory
    : : running and using than the DBTimage... let me know... if i did not
    : : understood your problem correctly maybe just state exactly what your
    : : objective with the program is and i might be able to give you a
    : : short cut of somekind....
    :
    : Thank you for the reply. You have understood perfectly. If you can
    : provide me with a shortcut I would be more than happy. Also if you
    : give me ur email id, I could probably send you a small
    : database(around 2 Mb)so that you can test it.
    :
    okay i'm first going to try the trick to see whether it works will let you know on Saturday email is simon@ld.co.za
    Good luck

    SimonPRG
Sign In or Register to comment.