Topic: Formatting problem
I have a number which will always be 7 digits wide. It is a Part Number.
I am getting a 'conversion' error when I retrieve the textbox contents (9999999) using sqlValue. The error I get is '''9999999''' is not a valid integer value.
If I use TEXT instead of sqlValue I still get the same error, but the value is shown as 20.
The aim of this code is to take the contents of a pre-filled set of text boxes and add as a new record back into the database. In other words, a previous order is reissued but now with the current date of issue.
In fact is their a simpler way to achieve what I'm trying to do?
procedure frmTechOrderDetails_btnReorder_OnClick (Sender: TObject; var Cancel: boolean);
var
dbSuppID, dbTechID,dbQty:integer;
dbPNum: cardinal;
dbPart,dbPCode:string;
begin
dbPart:= frmTechOrderDetails.edtPartDescription.sqlValue;
dbPCode:= frmTechOrderDetails.edtPartCode.sqlValue;
dbPNum:= strToInt(frmTechOrderDetails.edtPartNumber.sqlValue); //THIS IS THE CODE FAIL
dbQty:= strToInt(frmTechOrderDetails.edtQty.sqlValue);
dbTechID:= SQLExecute('SELECT id FROM techname WHERE tech = "'+ frmTechOrderDetails.edtTechName.text + '"');
dbSuppID:= SQLExecute('SELECT id FROM supplier WHERE sup_name= "'+ frmTechOrderDetails.edtSupplier.text + '"');
sqlExecute('INSERT INTO requests (id_techname, part, requestdate, id_supplier, partCode, partNumber, quantity) VALUES ("+dbTechID+",'+dbPart+',(DATE("now")),"+dbSuppId+",'+dbPCode+',"+dbPNum+","+dbQty")');
//debug message
showmessage('TechID = '+ intToStr(dbTechID) + ' SuppID = ' + intToStr(dbSuppID)+ 'Part name '+dbPart);
//end debug
end;