We help IT Professionals succeed at work.

Database methods with service application.

Jaymol
Jaymol asked
on
Hi,

I'm currently writing an application that I'd really like to be an NT service application.  It needs to update one table in a database with relevant information from another table, every now and again.

Basically, how do I use the TSQLConnection and TSQLQuery components within a service application.

I can connect to the DB (I think), but running a Query brings up an error message.

Does anyone know how to do this?

Thanks,

John.

(High points cos I really wanna do this.)
Comment
Watch Question

hi
you do it the same as any other application
you sure the error is Service Related ?
I've had no problems with services nor DB's
but I never made a DB service ...
can you specify the error ?
and give some code that produces the error
if you don't know how to debug a service it's in the help 'Debugging a service application'

Author

Commented:
No, it's a service related problem.  There is a known issue with creating a database application within a service.  Try it yourself, you'll see what I mean.

John

Author

Commented:
The line that causes the problem is this...

  SQLQuery.ExecSQL;

The sql statement is set like this...

  SQLQuery.SQL.Add('INSERT INTO SERVICE_TEST VALUES (''testval'')');

The database code works fine in a non-service application.

John.

Author

Commented:
I'm gonna award you the points cos you did say "you do it the same as any other application"

It turns out I was using the wrong user name and not actually able to see the table with that user's privileges.

Thanks for the help, even though it wasn't really necessary.

Ta,

John.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.