关于Adoquery的问题,求解答!在线等答案
先贴出代码吧:
procedure TFrmMain.Button2Click(Sender: TObject);begin if cxTextEdit1.text='' then exit ; if not idftp1.Connected then idftp1.Connect; adoquery1.Connection:=adoconnection1; ADOQuery1.Close; ADOQuery1.Open; showmessage(ADOQuery1.SQL.Text); ADOQuery1.SQL.Text:='select filename from test where shno='''+ cxTextEdit1.text+''''; Label1.caption:=adoquery1.FieldByName('filename').AsString ;end;procedure TFrmMain.Button2Click(Sender: TObject);begin if cxTextEdit1.text='' then exit ; if not idftp1.Connected then idftp1.Connect; if ADOConnection1.Connected then begin adoquery1.Connection:=adoconnection1; ADOQuery1.Close; ADOQuery1.SQL.Text := 'select filename from test where shno= '+QuotedStr(cxTextEdit1.text); showmessage(ADOQuery1.SQL.Text); ADOQuery1.Open; Label1.caption:=adoquery1.FieldByName('filename').AsString ; end else showmessage('ADOConnection1未连接。');end;
[解决办法]
ADOQuery1.SQL.Text 不能在 open 后才赋值。