在数据库中,DoctorID是整数列.编辑后的"//"代码行都不起作用.如果有人能告诉我如何在SQL语句中正确指定整数值,我将非常感激.
procedure TForm1.btnDeleteDocClick(Sender: TObject);
var
iID : Integer;
begin
iID := StrToInt (InputBox('Delete Doctor','Please enter in your Doctor ID',''));
with dmHospital do
begin
qryDoctors.SQL.Clear;
//qryDoctors.SQL.Add('DELETE FROM Doctors WHERE DoctorID = iID ' ) ;
//qryDoctors.SQL.Add('DELETE FROM Doctors WHERE DoctorID = ' + QuotedStr(iID));
qryDoctors.ExecSQL;
qryDoctors.SQL.Clear;
qryDoctors.SQL.Add('SELECT * FROM Doctors');
qryDoctors.Open;
end;
end;
Run Code Online (Sandbox Code Playgroud) 我试图从桌子上得到药物的价格,但我得到了:
procedure TForm1.BuyButtonClick(Sender: TObject);
var
iAmount : integer;
rRate : real;
sMedication : string;
sRate : string;
begin
iAmount := 0;
sMedication := BuyCombobox.Items[BuyCombobox.ItemIndex];
dmHospital.qryPrices.SQL.Clear;
dmHospital.qryPrices.SQL.Add('SELECT Price(R) FROM MedicationPrices WHERE Medication = quaotedstr(sMedication)');
sRate := dmHospital.qryPrices.SQL;
ShowMessage(sRate);
end;
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下代码将值插入MedicationPrices表.
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;
Run Code Online (Sandbox Code Playgroud)