[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 525
  • Last Modified:

use ADODataSet

hi all,

I use a update command in ADODataSet....

But it bring an error 'ADODataSet:commandtext does not return a result set' when I try ADODataSet.open

When I open the database,I found the update sql command is successful.

How to avoid the error popup?

who can help me? :) tks!
0
li_fang
Asked:
li_fang
  • 3
  • 3
  • 3
  • +1
1 Solution
 
ziolkoCommented:
ADO queries which dont return data should be called through TADOCommand or thereis possible workaround:
after update statement add dummy SQL like: select a=1. When useing TADODataSet or TADOQuery SQL statement must return at least 1 row.
ziolko.
0
 
geobulCommented:
Hi,

Use TADOQuery instead. Call its ExecSQL method. Open method must be used when the SQL statement returns a result set only. Use the optional lines below if you want to create the SQL statement in run-time.

with ADOQuery1 do begin
  Close;
  SQL.Clear; // optional
  SQL.Add('UPDATE ...); // optional
  ExecSQL;
end;

Regards, Geo
0
 
sfockCommented:
geobul

The use of TADOQuery, TADOStoredProc and TADOTable is not recommended. Borland has created this tree components to make it easier to migrate a project from BDE to ADO. After especially in Delphi5 these components have been very buggy and their arcitecture does not meet the arcitecture of ADO they should not be used if not nessesary.
The TADODataset and TADOCommand components are nothing but wrappers around the "original" COM Objects. For this reason it is most likely that there will be not "additional" problems occur when you use these.
Unless your solution will work perfectly, ziolko's TADOCommand solution is the "better" way to do it.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
geobulCommented:
Let me disagree. I've been using Delphi 5 ADO components for years. TADOQuery and TADODataSet are both direct descendants of TCustomADODataSet, which is actually that 'wrapper' you are talking about. Yes, there was a bug when Delphi 5 was initially released but it was fixed in the first patch.

Regards, Geo
0
 
sfockCommented:
geobul:

Well after you are right, that bugs i was talking about have been patched. Sorry i forgot to say. But after my intention has not been to say that TADOQuery would be "very buggy" this is not the point.
The main point is the different arcitecure. The fact that you can't take full advantage of ADO with a BDE Component architecture. I am sorry if this was not clear in my first posting.

Anyhow, like you i have also been using this components for years. And like you i prefer the ADOQuery to the ADODataset, but there are no good reasons for it except:
-You want to migrate from ADO to BDE or opposite
-You want to keep open to use both ways (why ever)

Anyhow i have to agree, that my point is not really important if you need ADO "only" to retrieve some data.

And let me say sorry i have not been intended to attack you in any case.
0
 
ziolkoCommented:
Hey guys if You really want to use "core ADO" You should use ADODataSet1.Recordset or even interfaces exposed by Microsoft:-)
ziolko.
0
 
geobulCommented:
sfock, I haven't ever thought you are attacking me ;-)

We share opinions here trying to help others and learning new things every day (at least I do).

TADOCommand could be used in that case, of course. The fact that I haven't mentioned it doesn't mean that I'm against it.

I'm not sure what you meant by saying:
> The use of TADOQuery, TADOStoredProc and TADOTable is not recommended.

Could you say where you've got this information from? I've never heard anything about this.

Regards, Geo
0
 
sfockCommented:
geobul
>I haven't ever thought you are attacking me ;-)
OK that's good! ;-)

Well the recomandation comes from Andreas Kosh. He is Author of a lot of Book's and Articles of the Topic Delphi. His latest Books have been "COM/DCOM and COM+ with Delphi" and "ADO and Delphi" After he is a german Author writing for a german publisher, i fear the Books are only available in German.
I would think, i have also read a similar statement on a borland page, but i can't find it anymore. I am sorry.
0
 
ziolkoCommented:
I dont know any recomendations about ADO only recomendation is my experience:-)) and I'm trying to use TADODataSet and TADOCommand to be honest with You I dont remember when I used TADOTable os TADOStoerdProc last time.
ziolko.
0
 
li_fangAuthor Commented:
tks for all comments!!!

I have known,that I will use TADOQuery instead .

zioloko's comment is great ! but I only can pay points to only one person:(

BEST REGARDS!
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

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