?
Solved

Update queery

Posted on 2005-02-23
11
Medium Priority
?
444 Views
Last Modified: 2010-04-05
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
Comment
Question by:Bosanac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +4
11 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13390612
Isnt your DVDID an integer if I remember back

'update films set available = QuotedStr('Yes') where dvd_ID ='+IntToStr(Currentdvd_ID);
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13390620
I think your delete call is getting confused as to what it is relating to .. the wwdbgrid1 or the wwdbgrid1.datasource.dataset
0
 
LVL 17

Expert Comment

by:geobul
ID: 13390630
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:geobul
ID: 13390650
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 13390745
>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
 

Author Comment

by:Bosanac
ID: 13391198
no the field is string...
I will check Meikl...
0
 
LVL 17

Accepted Solution

by:
geobul earned 200 total points
ID: 13391479
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 13391558
may be a possibility, too, geo
0
 
LVL 13

Expert Comment

by:Ashok
ID: 13393211
Are you using ACCESS database ?
0
 

Expert Comment

by:tortega_2001
ID: 13394321
Bosanac, try to use  ADOQuery3.SQL.Add instead of  ADOQuery3.SQL.Text. I think this modification resolve this event.
Regards
0
 

Expert Comment

by:krypto2000
ID: 13404900
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question