OK
- From: "DarkAngel" <support@xxxxxxxxxxxxx>
- Date: Tue, 25 Apr 2006 14:27:17 +0800
The following codes works fine:
procedure TMainForm.ws_deleteClick(Sender: TObject);
var
str:string;
begin
try
if application.MessageBox('confirm to delete?','Alert',MB_YESNO)=ID_YES
then
begin
str:=
tf_employee(activemdichild).dx1.DataSource.DataSet.Fields[1].AsString;
with dm.emp_sql do
begin
close;
sql.Clear;
sql.Add('delete from employees');
sql.Add('where job_id=:p');
parameters.ParamByName('p').Value :=str;
execsql;
end;
But still THANK YOU VERY MUCH.
"Bill Todd" <no@xxxxxx> дÈëÏûÏ¢ÐÂÎÅ:444d8483$1@xxxxxxxxxxxxxxxxxxxxxxxxx
DarkAngel wrote:
Hi, experts:
I use the following codes to delete a records from dbgrid:
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('delete from employees where job_id=:p');
adoquery1.Parameters.ParamByName('p').Value
:=dbgrid1.DataSource.DataSet.Fields[1].AsString;
I suspect you want the value from the first field in the dataset which
would be dbgrid1.DataSource.DataSet.Fields[0].AsString.
adoquery1.ExecSQL;
adoquery1.Open;
You should not call both the ExecSQL and the Open methods. Never call
Open for any SQL statement except SELECT. Use ExecSQL for all SQL
statements that do not return a result set.
and I got an error saying 'List index out of bounds'.
Probably because you used Fields[1] instead of Fields[0].
--
Bill Todd (TeamB)
.
- References:
- list index out of bounds
- From: DarkAngel
- Re: list index out of bounds
- From: Bill Todd
- list index out of bounds
- Prev by Date: Re: list index out of bounds
- Next by Date: Re: list index out of bounds
- Previous by thread: Re: list index out of bounds
- Index(es):
Relevant Pages
|