0
votes

While trying to connect to a database server via ODBC from a windows console program the connection is successful and getting data. But when i try to use same code in a windows service and at

odbc_connection.open();

I am getting this error

odbcERROR [08004] [Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve the connect identifier specified ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed

Any idea what configuration is missing on my machine. Some idea might be helpful

1
Have you already explored firewall issues? I have seen cases where users are able to successfully test connections through the ODBC Data Source Administrator or TNSPING, but are still not able to connect to the database itself. A quick test is trying to telnet the host defined in your TNS entry using the same specified port (i.e. (HOST = [machine])(PORT = 1521) -> telnet [machine] 1521).1991DBA

1 Answers

0
votes

Your service runs as some user. Usually, when you create service, it sets some default account there. When you run the code manually, it is executed under your privileges. When service runs the code, privileges are from the account under which service runs. Just go to this service and try to run as yourself

enter image description here