在表单中选择药品名称和数量,点击确认进行保存时,系统提示错误:Project Project1.exe raised exception class EOleException with message "在此上下文中不允许使用‘Text',此处只允许使用常量、表达式,或变量。不允许使用列明。
错误标志在我划横线的那一行。
代码如下:
procedure TForm6.Button1Click(Sender: TObject);
begin
DataM.ADOQuery5.Connection:=DataM.ADOConnection1;
DataM.ADOQuery5.Close;
DataM.ADOQuery5.SQL.Clear;
DataM.ADOQuery5.SQL.Text:='insert into 用户药品表 values('''+Form3.E_pname.Text+''',StrToFloat(Form3.E_singleprice.Text),StrToInt(Form3.E_dn.Text))';
DataM.ADOQuery5.ExecSQL;
DataM.ADOQuery3.Connection:=DataM.ADOConnection1; ??——————错误在这一行——————???
DataM.ADOQuery3.Close;
DataM.ADOQuery3.SQL.Clear;
DataM.ADOQuery3.SQL.Text:='update drugs set remain=remain-StrToInt(Form3.E_dn.text) where drugname='''+Form3.E_pname.Text+'''';
DataM.ADOQuery3.ExecSQL;
showmessage('添加成功');
Form3.Show;
Form6.Close;
end;
错误标志在我划横线的那一行。
代码如下:
procedure TForm6.Button1Click(Sender: TObject);
begin
DataM.ADOQuery5.Connection:=DataM.ADOConnection1;
DataM.ADOQuery5.Close;
DataM.ADOQuery5.SQL.Clear;
DataM.ADOQuery5.SQL.Text:='insert into 用户药品表 values('''+Form3.E_pname.Text+''',StrToFloat(Form3.E_singleprice.Text),StrToInt(Form3.E_dn.Text))';
DataM.ADOQuery5.ExecSQL;
DataM.ADOQuery3.Connection:=DataM.ADOConnection1; ??——————错误在这一行——————???
DataM.ADOQuery3.Close;
DataM.ADOQuery3.SQL.Clear;
DataM.ADOQuery3.SQL.Text:='update drugs set remain=remain-StrToInt(Form3.E_dn.text) where drugname='''+Form3.E_pname.Text+'''';
DataM.ADOQuery3.ExecSQL;
showmessage('添加成功');
Form3.Show;
Form6.Close;
end;
DataM.ADOQuery3.SQL.Text:='update drugs set remain=remain-StrToInt(Form3.E_dn.text) where drugname='''+Form3.E_pname.Text+''''; 中set remain=remain-StrToInt(Form3.E_dn.text),这对吗StrToInt(Form3.E_dn.text)怎能直接放到sql语句中呢
'insert into 用户药品表 '那句也有着问题,自己看一下
另一个类似,自己改吧
+''',''' + Form3.E_dn.Text + ''')';