Board index » delphi » ENoResultSet: Error Creating Cursor Handle

ENoResultSet: Error Creating Cursor Handle

I'm trying to use the SQL property of a TQuery component with the
following code:

with Query1 do begin
      Active := False;
      SQL.Clear;
      SQL.Add('Create table MyTable');
      SQL.Add('(au_id char(10), au_name char(30))');
      try
         Active := True;
      except
         on E: Exception do begin
            ShowMessage(E.Message);
         end;
      end;
      Table2.TableName := 'MYTABLE.DBF';
      Table2.Active := True;
   end;

The table is created and the 2 lines after the end of the try... block
excute and open the table just fine.  I can create a silent exception to
workaround, I'm just wondering if anyone knows exactly what this error
means.

Thanks for any info!

Joe
jkocin...@toltbbs.com

 

Re:ENoResultSet: Error Creating Cursor Handle


If your query statement doen't return a results set use ExecSQL instead of
Active := TRUE or Open.
Creating a table does not return a result set.

Marshall Watts
wa...@inlink.com

Quote
Joe Kocinski wrote:
> I'm trying to use the SQL property of a TQuery component with the
> following code:

> with Query1 do begin
>       Active := False;
>       SQL.Clear;
>       SQL.Add('Create table MyTable');
>       SQL.Add('(au_id char(10), au_name char(30))');
>       try
>          Active := True;
>       except
>          on E: Exception do begin
>             ShowMessage(E.Message);
>          end;
>       end;
>       Table2.TableName := 'MYTABLE.DBF';
>       Table2.Active := True;
>    end;

> The table is created and the 2 lines after the end of the try... block
> excute and open the table just fine.  I can create a silent exception to
> workaround, I'm just wondering if anyone knows exactly what this error
> means.

> Thanks for any info!

> Joe
> jkocin...@toltbbs.com

Re:ENoResultSet: Error Creating Cursor Handle


For SQL DDL statements you must call the TQuery.ExecSQL method instead
of calling open or setting Active to True.  This is described in the
on-line help.

Bill

(Sorry but TeamB cannot answer support questions received via email.)
(To send me email for any other reason remove .nospam from my address.)

Other Threads