Forum > Databases
ODBC Connection in a Windows service
relocate:
I want to connect to an MSSQL Server via a service in Windows.
But it won't connect.
In a standard program everything works as it should, but not in the service.
The suggested solution to create a system DNS doesn't help.
The handles are created, only when it comes to the Connection it goes wrong.
I dont't use Lazarus only pure Free Pascal and the odbcsqldyn unit.
ccrause:
Just thinking out loud - could this be a privilege issue because the service doesn't run within a user context? Can you retrieve an error code, this could help in identifying the problem.
Zvoni:
1) is your service dependent on the Database-Service? As in: Is the DB-Service up and running, before your Service starts?
2) Have you tried within your service to Login with your Windows-user-Account?
https://www.codeproject.com/Questions/185651/ODBC-through-Windows-Service-Win-7-x64
relocate:
@ccrause
I only get -1 as errorcode. That's the returncode from SQLConnect, I don't know if i can get any other code.
@zvoni
1) No, the Database is located on an server which is allready running, so no dependences.
2) Yes, I allready tried it. But you brought me onto the right course, I took the wrong user. (local instead of domain user), it works, thank you!
Zvoni:
Ah, yes.
Domain-User makes more sense, if the DB-Server is on another machine of the Network
Navigation
[0] Message Index
[#] Next page