Board index » delphi » error creating cursor handling for TQuery component with Insert SQL command

error creating cursor handling for TQuery component with Insert SQL command

Hi,
I am now deviloping 3-tiers application . and I have problem when I
Insert data to table uses TQuery component.
It's show error message ' Error creating cursor handling'  , I use this
component both in app server and client app.
In client app , I send parameters to TQuery component in Remote data
module of app server.  It difference that Exception class of app server
is ENoResultSet and in client app the Exeption class is EOLE

code in app server like this
    with DataModule1.QueryInsertOT do
    begin
      close;
      unprepare;
      params[0].AsInteger := ID;
      params[1].AsDateTime := daywork;
      params[2].AsFloat := otHours;
      prepare;
      open;
      next;
    end;

 I dont know what a mistake of this code , anybody tell me the right
code .  thanks...
  Suyada Libprapakorn
suy...@hotmail.com

 

Re:error creating cursor handling for TQuery component with Insert SQL command


You shouldn't be opening non select statments.  You should ExecSQL instead.
Insert SQL does not return a cursor and therefor Open can't create a cursor
handle for it.  Your use of Prepare and Unprepare is wrong too.  Prepare the SQL
once before the loop and unprepare it once after the loop is completed.

Quote
Suyada Libprapakorn wrote:

> Hi,
> I am now deviloping 3-tiers application . and I have problem when I
> Insert data to table uses TQuery component.
> It's show error message ' Error creating cursor handling'  , I use this
> component both in app server and client app.
> In client app , I send parameters to TQuery component in Remote data
> module of app server.  It difference that Exception class of app server
> is ENoResultSet and in client app the Exeption class is EOLE

> code in app server like this
>     with DataModule1.QueryInsertOT do
>     begin
>       close;
>       unprepare;
>       params[0].AsInteger := ID;
>       params[1].AsDateTime := daywork;
>       params[2].AsFloat := otHours;
>       prepare;
>       open;
>       next;
>     end;

>  I dont know what a mistake of this code , anybody tell me the right
> code .  thanks...
>   Suyada Libprapakorn
> suy...@hotmail.com

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
If there is somebody up there could they throw me down a line.  Just a
little helping hand just a little understanding.  Just some answers to the
questions that surround me now.  If there's somebody up there could
they throw me down a line.               (Fish)

Re:error creating cursor handling for TQuery component with Insert SQL command


and in client app , I use sendparams method , but if SQL command is Insert ,it's has
the same problem , Error Message'Error creating cursor handling'  Exception class is
EOleException, what method I should use to send this params to app server.
a line of code is
clientdataset1.close;
clieantdataset1.params[0].AsInteger := ID;
clientdataset1.open;
clientdataset1.sendparams;
I think error from open clientdatset , but if it dont open clientdataset , it cant
insert to database.
what is the right code for this ..
thanks.
Quote
"Jeff Overcash (TeamB)" wrote:
> You shouldn't be opening non select statments.  You should ExecSQL instead.
> Insert SQL does not return a cursor and therefor Open can't create a cursor
> handle for it.  Your use of Prepare and Unprepare is wrong too.  Prepare the SQL
> once before the loop and unprepare it once after the loop is completed.

> Suyada Libprapakorn wrote:

> > Hi,
> > I am now deviloping 3-tiers application . and I have problem when I
> > Insert data to table uses TQuery component.
> > It's show error message ' Error creating cursor handling'  , I use this
> > component both in app server and client app.
> > In client app , I send parameters to TQuery component in Remote data
> > module of app server.  It difference that Exception class of app server
> > is ENoResultSet and in client app the Exeption class is EOLE

> > code in app server like this
> >     with DataModule1.QueryInsertOT do
> >     begin
> >       close;
> >       unprepare;
> >       params[0].AsInteger := ID;
> >       params[1].AsDateTime := daywork;
> >       params[2].AsFloat := otHours;
> >       prepare;
> >       open;
> >       next;
> >     end;

> >  I dont know what a mistake of this code , anybody tell me the right
> > code .  thanks...
> >   Suyada Libprapakorn
> > suy...@hotmail.com

> --
> Jeff Overcash (TeamB)
>       (Please do not email me directly unless  asked. Thank You)
> If there is somebody up there could they throw me down a line.  Just a
> little helping hand just a little understanding.  Just some answers to the
> questions that surround me now.  If there's somebody up there could
> they throw me down a line.               (Fish)

Re:error creating cursor handling for TQuery component with Insert SQL command


and if I send params for TQuery component with insert command , if I cant open
clientdataset,so cant insert data to database , what the right coding for this
operation.
my code is
clientDataset1.close;
clientDataset1.params[0].asInteger := ID;
clientDataset1.open;
clientDataset1.sendparams;
Quote
"Jeff Overcash (TeamB)" wrote:
> You shouldn't be opening non select statments.  You should ExecSQL instead.
> Insert SQL does not return a cursor and therefor Open can't create a cursor
> handle for it.  Your use of Prepare and Unprepare is wrong too.  Prepare the SQL
> once before the loop and unprepare it once after the loop is completed.

> Suyada Libprapakorn wrote:

> > Hi,
> > I am now deviloping 3-tiers application . and I have problem when I
> > Insert data to table uses TQuery component.
> > It's show error message ' Error creating cursor handling'  , I use this
> > component both in app server and client app.
> > In client app , I send parameters to TQuery component in Remote data
> > module of app server.  It difference that Exception class of app server
> > is ENoResultSet and in client app the Exeption class is EOLE

> > code in app server like this
> >     with DataModule1.QueryInsertOT do
> >     begin
> >       close;
> >       unprepare;
> >       params[0].AsInteger := ID;
> >       params[1].AsDateTime := daywork;
> >       params[2].AsFloat := otHours;
> >       prepare;
> >       open;
> >       next;
> >     end;

> >  I dont know what a mistake of this code , anybody tell me the right
> > code .  thanks...
> >   Suyada Libprapakorn
> > suy...@hotmail.com

> --
> Jeff Overcash (TeamB)
>       (Please do not email me directly unless  asked. Thank You)
> If there is somebody up there could they throw me down a line.  Just a
> little helping hand just a little understanding.  Just some answers to the
> questions that surround me now.  If there's somebody up there could
> they throw me down a line.               (Fish)

Re:error creating cursor handling for TQuery component with Insert SQL command


and if I send params for TQuery component with insert command , if I cant open
clientdataset,so cant insert data to database , what the right coding for this
operation.
my code is
clientDataset1.close;
clientDataset1.params[0].asInteger := ID;
clientDataset1.open;
clientDataset1.sendparams;
Quote
"Jeff Overcash (TeamB)" wrote:
> You shouldn't be opening non select statments.  You should ExecSQL instead.
> Insert SQL does not return a cursor and therefor Open can't create a cursor
> handle for it.  Your use of Prepare and Unprepare is wrong too.  Prepare the SQL
> once before the loop and unprepare it once after the loop is completed.

> Suyada Libprapakorn wrote:

> > Hi,
> > I am now deviloping 3-tiers application . and I have problem when I
> > Insert data to table uses TQuery component.
> > It's show error message ' Error creating cursor handling'  , I use this
> > component both in app server and client app.
> > In client app , I send parameters to TQuery component in Remote data
> > module of app server.  It difference that Exception class of app server
> > is ENoResultSet and in client app the Exeption class is EOLE

> > code in app server like this
> >     with DataModule1.QueryInsertOT do
> >     begin
> >       close;
> >       unprepare;
> >       params[0].AsInteger := ID;
> >       params[1].AsDateTime := daywork;
> >       params[2].AsFloat := otHours;
> >       prepare;
> >       open;
> >       next;
> >     end;

> >  I dont know what a mistake of this code , anybody tell me the right
> > code .  thanks...
> >   Suyada Libprapakorn
> > suy...@hotmail.com

> --
> Jeff Overcash (TeamB)
>       (Please do not email me directly unless  asked. Thank You)
> If there is somebody up there could they throw me down a line.  Just a
> little helping hand just a little understanding.  Just some answers to the
> questions that surround me now.  If there's somebody up there could
> they throw me down a line.               (Fish)

Other Threads