Topic: "" is not a valid integer value. where there is not a match in the db

this line causes this error when there is no match in the database

ContID := SQLExecute('SELECT id FROM Containers WHERE containerid=' + trfcontid );

["" is not a valid integer value.]

I would like to catch this error and rather open the form to add the value to the database

I tried this

if ContID = '' then
             begin
             frmContEdit.contID.Text := trfcontid;
             frmContEdit.Show;
             end;

and it does get the value and pass it to the add container form, but it still does the error first.  how do I get rid of that?

Re: "" is not a valid integer value. where there is not a match in the db

Try this:

var
   sContID: string;
begin
   sContID := SQLExecute('SELECT id FROM Containers WHERE containerid=' + trfcontid );
   if sContID='' then
   begin
             frmContEdit.contID.Text := trfcontid;
             frmContEdit.Show;
   end;
Dmitry.

Re: "" is not a valid integer value. where there is not a match in the db

Here is the entire code - It still does the same - tell me if you see something here.

procedure FillAContainer_conttextlookup_Onexit (Sender: string);
var
   trfcontid, ContID: string;
   sContID: string;

begin
     trfcontid := FillAContainer.conttextlookup.Text;
     if Length(trfcontid) < 10 then
         begin
             subcontainerfind.Containerids.Text := trfcontid;
             FillAContainer.SearchContainer.Click;

         end
     else
         begin
             sContID := SQLExecute('SELECT id FROM Containers WHERE containerid=' + trfcontid );
             if sContID='' then
                begin
                     frmContEdit.contID.Text := trfcontid;
                     frmContEdit.Show;
               end;
             FillAContainer.Containerid.dbItemID := strtoint(ContID);
             fillcontform(ContID);
         end;

end;

Re: "" is not a valid integer value. where there is not a match in the db

difficult to say something just for this part of the code

Dmitry.

Re: "" is not a valid integer value. where there is not a match in the db

@timlitw
from your error message and the variable definition, it looks like the variable trfcontid is defined as a string, but is used to look up information in the table that expects it to be an integer.
the simplest way to overcome the error is either redefine the variabe as in integer (along with ContID), or to check the value before before passing it to the SQL statement:

if (trfcontid = '') then trfcontid = '0';

this would only solve the erro part of the problem and does not help to add it into the database if it is missing; you should be able to do this after the SQL is run and a checking the result of ContID, and actioning as appropriate.

Dennis

Re: "" is not a valid integer value. where there is not a match in the db

if trfcontid = '' then trfcontid := '0';

Re: "" is not a valid integer value. where there is not a match in the db

trfcondid is the text string from the field that that bar code scanner "types" into.   

the sql takes that text string and looks up the container id if it exists from the container table, then it puts the id into the drop down list so that there are 2 method of entering the container, the drop down that has a incremental search feeding it if the bar code reader battery is down or the bar code reader output,  that appends a <cr> at the end of its output.

Re: "" is not a valid integer value. where there is not a match in the db

hmm - the sContID should be integer - i'll post the whole thng again with comments for each line if changing that still has problems.

Re: "" is not a valid integer value. where there is not a match in the db

your comments helped me look in the right place - here is the working code with comments before each line

procedure FillAContainer_conttextlookup_Onexit (Sender: string);
var
   trfcontid : string; // form field that bar code reader types into
   sContID: integer;    // should hold the database record id of the container should be !!integer!!

begin
    // get bar code scan entry from form
     trfcontid := FillAContainer.conttextlookup.Text;
     // check if correct amount of digits
     if Length(trfcontid) < 10 then
         begin
             // if not less than 10 digits open container list to find container
             subcontainerfind.Containerids.Text := trfcontid;
             // click button to open subcontainer form
             FillAContainer.SearchContainer.Click;
         end
     else
         begin
             // look up container id from from container name
             sContID := SQLExecute('SELECT id FROM Containers WHERE containerid=' + trfcontid );
             // check if it returned empty
             if sContID=0 then
                begin
                     // if empty take input from scanner field and put it into add new container form
                     frmContEdit.contID.Text := trfcontid;
                     // open new container form to finish adding new container
                     frmContEdit.Show;
               end;
             // put id of container into drop down in fillacontainer form
             FillAContainer.Containerid.dbItemID := sContID;
             // call the form fill lookups to fill other fields base on the container selected
             fillcontform(inttostr(sContID));
         end;

end;

Re: "" is not a valid integer value. where there is not a match in the db

timlitw
Please, send me your project to support@drive-software.com
with description of problem.

Dmitry.

Re: "" is not a valid integer value. where there is not a match in the db

привет помогите пожалуйста с аналогичной проблемой
пишет  "" is not a valid integer value. при попытке редактирования записи


я новичеок так что подскажите пожалуйста что нужно для этого

Re: "" is not a valid integer value. where there is not a match in the db

haka21 wrote:

привет помогите пожалуйста с аналогичной проблемой
пишет  "" is not a valid integer value. при попытке редактирования записи


я новичеок так что подскажите пожалуйста что нужно для этого

Приветствую,


Пожалуйста отправьте ваш проект на support@drive-software.com
с описанием действий,которые приводят к данной ошибки.

Dmitry.