Click here to Skip to main content
15,115,557 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I recently moved my dev. environment from XP to windows 7 64 bit. We still need to use VS 2003.NET due to old library compatibility, which isn't an issue.

I have a Windows Service project which uses an ODBC library we have to connect to a database. Here's where the strange starts happening. For whatever reason, I am unable to get a connection to the database (local or on the network) via the service in windows 7. On an XP machine, it works just fine.

Other apps that use the exact same library are able to connect as well (local or network), but for whatever reason, the service in windows 7 cannot connect. The connection statement used is below:

sql_ret = SQLDriverConnect(m_sqlConn, NULL, (SQLCHAR*)m_szConnectParam.c_str(),
                            SQL_NTS, (SQLCHAR*)szConnectOutput, HUGE_STR,

sql_ret comes back as -1. No other errors or indications are given. Again, this same exact line is used to successfully connect from other C++ dialog apps in Windows 7.

I have tried multiple accounts as well (networkservice, admin, local account) but nothing seems to work. Hope you can help!

Nish Nishant 22-Apr-11 11:11am
Question. If you run your code in a desktop app, does it work?
Sandeep Mewara 22-Apr-11 11:51am
OP replied:
Yes, the same code is used in the desktop apps I've tried, and works perfectly.
bzzoy 22-Apr-11 11:25am
Yes, the same code is used in the desktop apps I've tried, and works perfectly.

1 solution

Well, I guess I tried every login except my domain account. Setting the service to login as that, I was able to get the connection.

edit: I suppose the clear solution is that its a login issue from the service. I am not sure why only the domain account is working at this point, but I have a general direction.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900