Board index » delphi » Error creating cursor handle with an INSERT SQL query

Error creating cursor handle with an INSERT SQL query

        I tried to create an INSERT SQL query, a very simple one, but which I
really need. Since I'm not a very good SQL-programmer, I first created that
query with the QBE of Paradox. The QBE query worked properly, so I tried to use
its SQL translation, which is provided by Paradox. With Paradox, this SQL query
went on working properly. But when inserted in the SQL property of a Tquery
object, I couldn't make this object active : a message "Error when creating
cursor handle" appeared. If you know the reason why, and the way to solve that
problem, it would be very helpful?
        Thanks in advance. My e-mail is duran...@worldnet.fr     :-)

 

Re:Error creating cursor handle with an INSERT SQL query


Sounds like you may not have been supplying the full pathname or alias
to the table(s) used in the query.

To use an alias in SQL statement:
     Select <whatever> from ":MYALIAS:MYTABLE"

In article <6eu1d2$ih...@news3.isdnet.net>, gouy (duran...@worldnet.fr)
writes:  

Quote
>       I tried to create an INSERT SQL query, a very simple

one, but which I  >really need. Since I'm not a very good
SQL-programmer, I first created that  >query with the QBE of Paradox.
The QBE query worked properly, so I tried to use  >its SQL translation,
which is provided by Paradox. With Paradox, this SQL query  >went on
working properly. But when inserted in the SQL property of a Tquery
Quote
>object, I couldn't make this object active : a message "Error when creating
>cursor handle" appeared. If you know the reason why, and the way to solve that
>problem, it would be very helpful?
>       Thanks in advance. My e-mail is duran...@worldnet.fr     :-)

Re:Error creating cursor handle with an INSERT SQL query


Use ExecSql instead of query1.open

In article <6eu1d2$ih...@news3.isdnet.net>, duran...@worldnet.fr says...
:       I tried to create an INSERT SQL query, ...
: I couldn't make this object active : a message "Error when creating
: cursor handle" appeared. If you know the reason why,
: and the way to solve that
: problem, it would be very helpful?
:       Thanks in advance. My e-mail is duran...@worldnet.fr     :-)
:
:

Re:Error creating cursor handle with an INSERT SQL query


I had to get help with this one myself. Having used MS Access for years,
I'd never heard of ExecSQL.

Query.ExecSql is used for update, create, insert queries because these
queries don't create a table cursor. Query.open, on the other hand, does
create a cursor.
Here is some sample code, too. What I am doing in this code is emptying
a temporary table and then inserting records from another table into the
temporary table:

var
        query1:TQuery;
begin
     query1 := nil;
  try
     table1.close;
     table1.emptytable;
     query1 := tquery.create(nil);
     with query1 do begin
          databasename := 'DBDEMOS';
          close;
          sql.clear;
          sql.add('insert into temp.db');
          sql.add('select * from parts.db');
          sql.add('where vendorno < 6000');
          execsql; //query1.execsql instead of query1.open
     end;
    except on e:exception do
           ShowMessage(e.message);
    end;

        if assigned(query1) then begin
           query1.close;
           query1.free ;
           table1.open;
        end;
end;

In article <6eu1d2$ih...@news3.isdnet.net>, duran...@worldnet.fr says...
:       I tried to create an INSERT SQL query
:
:

Other Threads