Link to home
Start Free TrialLog in
Avatar of Bosanac
Bosanac

asked on

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??
Avatar of Mike Littlewood
Mike Littlewood
Flag of United Kingdom of Great Britain and Northern Ireland image

Isnt your DVDID an integer if I remember back

'update films set available = QuotedStr('Yes') where dvd_ID ='+IntToStr(Currentdvd_ID);
I think your delete call is getting confused as to what it is relating to .. the wwdbgrid1 or the wwdbgrid1.datasource.dataset
Avatar of geobul
geobul

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
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
Avatar of kretzschmar
>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
Avatar of Bosanac

ASKER

no the field is string...
I will check Meikl...
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
may be a possibility, too, geo
Are you using ACCESS database ?
Bosanac, try to use  ADOQuery3.SQL.Add instead of  ADOQuery3.SQL.Text. I think this modification resolve this event.
Regards
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...