• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 451
  • Last Modified:

Update queery

here is the code :

procedure TForm6.ADOTable1AfterDelete(DataSet: TDataSet);    //this is what seems to go  wrong
begin
ADOQuery3.Close;
ADOQuery3.SQL.Clear;
ADOQuery3.SQL.Text:= 'update films set available =''yes'' where dvd_ID ='+QuotedStr(Currentdvd_ID);
ADOQuery3.ExecSQL;
end;

procedure TForm6.ADOTable1BeforeDelete(DataSet: TDataSet);
begin
Currentdvd_ID := wwDBGrid1.Datasource.Dataset.FieldbyName('dvd_ID').value;
end;



procedure TForm6.BitBtn1Click(Sender: TObject);  //delete button
 var i:integer;
begin
  with wwdbgrid1, wwdbgrid1.datasource.dataset do begin
      DisableControls;     { Disable controls to improve performance }
      for i:= 0 to SelectedList.Count-1 do begin
         GotoBookmark(SelectedList.items[i]);
         Freebookmark(SelectedList.items[i]);
         Delete;          
      end;
      SelectedList.clear;  
      EnableControls;      
    end;
 end;

form variable is declared :var Currentdvd_ID: string;

When I delete the record
 I get :


Project Project1.exe raised exception class EOleException with message 'Current provider
does not support returning multiple recordsets from a single execution'.Process stopped.Use...."

Why??
0
Bosanac
Asked:
Bosanac
  • 3
  • 2
  • 2
  • +4
1 Solution
 
mikelittlewoodCommented:
Isnt your DVDID an integer if I remember back

'update films set available = QuotedStr('Yes') where dvd_ID ='+IntToStr(Currentdvd_ID);
0
 
mikelittlewoodCommented:
I think your delete call is getting confused as to what it is relating to .. the wwdbgrid1 or the wwdbgrid1.datasource.dataset
0
 
geobulCommented:
Hi,

1. dvd_ID field in films table should be of string type. In that case your UPDATE sql seems correct.

2. If you used TDBGrid I'd try:

procedure TForm6.BitBtn1Click(Sender: TObject);  //delete button
 var i:integer;
begin
  wwdbgrid1.SelectedRows.Delete;
end;

Regards, Geo
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
geobulCommented:
If dvd_ID is integer then:

var Currentdvd_ID: integer;
...
ADOQuery3.SQL.Text:= 'update films set available =''yes'' where dvd_ID ='+IntToStr(Currentdvd_ID);

BTW you have another table opened in the grid not the 'films' table, right?

Regards, Geo
0
 
kretzschmarCommented:
>Project Project1.exe raised exception class EOleException with message 'Current provider
>does not support returning multiple recordsets from a single execution'.Process
>stopped.Use...."

guessing you use somewhere an ADOQuery3.Open
0
 
BosanacAuthor Commented:
no the field is string...
I will check Meikl...
0
 
geobulCommented:
Hi,

Meikl led me into another direction: you're using ADOQuery3 somewhere else without clearing its SQL property first (and using SQL.Add method instead of SQL.Text :=..). Thus, you, at a sertain point, end up with two or more SQL statements in ADOQuery3.SQL.

Regards, Geo
0
 
kretzschmarCommented:
may be a possibility, too, geo
0
 
AshokCommented:
Are you using ACCESS database ?
0
 
tortega_2001Commented:
Bosanac, try to use  ADOQuery3.SQL.Add instead of  ADOQuery3.SQL.Text. I think this modification resolve this event.
Regards
0
 
krypto2000Commented:
try this :


SQL := 'update films set available = :availableState where dvd_ID ='+QuotedStr(Currentdvd_ID);

ADOQuery.Paramaters.ParamByName('availableState').Value := 'yes';
ADOQuery.ExecSQL;

Maybe that could help you...

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now