help with random error - Programmers Heaven

Howdy, Stranger!

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

Categories

help with random error

bcTune33bcTune33 Posts: 12Member
I am writing a program which accesses a Microsoft Access database and inserts baseball card info in.

The program works flawlessly 95% of the time, however I get this random error which crashes the program.

It says: "Could not convert variant of type (Null) into type (string).

Any Ideas? If it would help I can upload or email a copy of my files.

Please let me know if anyone has seen this...I'm new to delphi but I've put alot of time into this program.
*----------------------------------------*

There are two ways to write error-free programs; only the third one works.


Comments

  • bcTune33bcTune33 Posts: 12Member
    *update*

    OK it seems to have something to do with the following:

    Before a new record is sorted, the program checks to see if the record exists, if so, it just updates the quantity field and total value field.

    I check by using a series of nested if then statements.

    The field that seems to be causing the problem is named 'CardDesc'. It contains special information of the card (ie if it is a gold card, rookie card, etc.) the problem seems to arise when there is nothing in the field at all. The program tries to set CardDescStr:=ADOTable2.FieldByName('cardDesc').value;
    and I'm guessing that's where the error comes from. Any ideas?
    *----------------------------------------*

    There are two ways to write error-free programs; only the third one works.



  • UlvertUlvert Posts: 58Member
    : *update*
    :
    : OK it seems to have something to do with the following:
    :
    : Before a new record is sorted, the program checks to see if the record exists, if so, it just updates the quantity field and total value field.
    :
    : I check by using a series of nested if then statements.
    :
    : The field that seems to be causing the problem is named 'CardDesc'. It contains special information of the card (ie if it is a gold card, rookie card, etc.) the problem seems to arise when there is nothing in the field at all. The program tries to set CardDescStr:=ADOTable2.FieldByName('cardDesc').value;
    : and I'm guessing that's where the error comes from. Any ideas?
    : *----------------------------------------*
    :
    : There are two ways to write error-free programs; only the third one works.
    :
    :
    :
    :

    Why do you use .Value for FieldByName and not .AsString if you know that it is a string?

    I always use specific .AsString, .AsInteger, AsBoolean, etc and find that it works very well for me.

    //Ulvert

Sign In or Register to comment.