TStringGrid Cells are rows. an attempt to assign a string directly to a digital field will throw an exception.
Thus, it is good practice to assign values ββto database fields via AsString , AsInteger , AsBoolean , etc ... this will result in the correct conversion.
In your code use:
TBLOrderedItem.FieldByName('ItemID').AsString := StringGrid1.Cells[1, count];
The same is true for Quantity .
To assign an Integer value, use:
TBLOrderedItem.FieldByName('OrderID').AsInteger := intNumber + 1;
By the way, you forgot TBLOrder.Post ie:
.... TBLOrder.Append; TBLOrder.FieldByName('CustomerID').AsInteger := CompanyName.ItemIndex + 1; TBLOrder.FieldByName('OrderID').AsInteger := intNumber + 1; TBLOrder.Post; ...
Finally, I would also suggest renaming TBLOrder to TBLOrder so that this name does not mean that it is Type .
kobik source share