我想用下面的代碼將值插入到MedicationPrices表中。如何使用SQL將實數值插入到表中?
procedure TForm1.btnAddMedicineClick(Sender: TObject);
var
sMedication, sQuantity : string;
rPrice : real;
begin
sMedication := InputBox('Add Medication','Please enter the medications name','');
sQuantity := InputBox('Add Medication','Please enter the the quantity','');
rPrice := StrToFloat(InputBox('Add Medication','Please enter the the price',''));
with dmHospital do
begin
qryPrices.SQL.Clear;
qryPrices.SQL.Add('INSERT INTO MedicationPrices (Medication, Quantity)');
qryPrices.SQL.Add('VALUES(' + QuotedStr(sMedication) +',' + QuotedStr(sQuantity) + ')');
qryPrices.Parameters.ParamByName('Price').Value := rPrice;
qryPrices.ExecSQL;
qryPrices.SQL.Clear;
qryPrices.SQL.Text := 'SELECT * MedicationPrices ';
qryPrices.Open;
end;
end;
我想你錯過了列(又名字段)名稱和查詢參數之間的區別。它們不是同一件事。 – MartynA
我不願意在這家醫院找到自己: -/ –
with..do應該永遠被禁止imo –