Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Query or ADOCommand Error

Status
Not open for further replies.

Ginka

Programmer
Mar 18, 2005
54
0
0
MX
Query->Close();
Query->SQL->Clear();
Query->SQL->Add("SELECT *");
Query->SQL->Add("INTO MyTable");
Query->SQL->Add("FROM OriginalTable");
Query->ExecSQL();

It doesn't work!!

Also I put the SQL code into a ADOCommand
if I double click the command in design time it works (put the query into MyTable), but if I execute the command in run time it doesn't work

Why??!!!!!!



 
I've used ADO only in a limited context so take my advice for what's its worth (probably useless :) .) My understanding is a query must return a record set. If is does not, you get an error.

If you want to execute a SQL statement that does not return a record set you have to use the command set. Having said that, I notice that in the book it says you can get around this via a try...catch statement and catch the ENoResultSet exception.

I've not used the ADOCommand so I can't say how it works. Are you getting a specific error or does the command just fail?

James P. Cottingham
-----------------------------------------
[sup]To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.[/sup]
 
ExecSQL() only works with commands that don't return a result set eg. update, delete, etc
If you are using a statement that returns a result set (eg select), you must use Open() instead of ExecSQL()

The same applies to stored procedures (Open()/ExecProc())

Hope that helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top