3

I had built an application to connect to MySQL DB and SyBase - SQL Anywhere DB using VB.NET and appropriate ODBC connections. This was working fine until we had to make this application a service which keeps running in the background irrespective of any users logged in.

I built the application into a service and after installation, the service was able to successfully connect to MySQL DB, but I am getting the following error when connecting to SyBase (please note the connection string is exactly same as used in the application)

ERROR [08001] [Sybase][ODBC Driver][SQL Anywhere]Database server not found

The project installer - service process installer 1 is configured as localsystem.

The creepiest thing here is, mysql connection is successful, when the same application was not a service, connecting to sybase was successful. Once it was made into a service it started failing. I have a Windows 7 64-bit workstation and VS 2010.

I have been trying to do every single thing for the last one week to fix it but nothing seems to be working. Any advice would be highly appreciated.

rekire
  • 47,260
  • 30
  • 167
  • 264
Aaron
  • 41
  • 1
  • 4

2 Answers2

4

Looks like you are using a DSN to connect to SQL Anywhere.

First, make sure that you have configured it as a System DSN. Then, verify that you are using a TCP/IP connection protocol (ODBC Admin -> Select System DSN tab -> Select DSN in list -> Click Configure -> Goto Network tab) and NOT Shared Memory.

Using Shared Memory will NOT work from a Win Service that tries to connect to a SQL Anywhere DB Server. I suspect that is the issue since you are able to connect from a desktop app using the same connection string.

One way to make this work is to start your SQL Anywhere db as a network server (Start -> All Programs -> Sql Anywhere 12 (or 11, depending on your setup) -> SQL Anywhere -> Network Server.

That should run the dbsvr12.exe, which will start listening for connections on a TCP port.

Then, add a Links=tcpip, or a Host=localhost to your Win Service connection string and give that a try!

tzup
  • 3,566
  • 3
  • 26
  • 34
  • 2
    This is and old question, but wanted to add a comment anyways. I had a very similar situation and adding Links=tcpip fixed the issue for me. – Deke Dec 18 '14 at 20:23
  • Even creating the DSN with TCP/IP connection protocol, doesn't allow it. We have to add `Links=tcpip` parameter in the connection string along with DSN Name. – Shell Jan 10 '23 at 13:12
0

Take notice that simple win app is running with credentials from logged user, while windows service is running on system account (in your case). You have two options, change connection string to connect with specific user (if you are now using trusted connection) or change windows service logon user to your user.

Gregor Primar
  • 6,759
  • 2
  • 33
  • 46
  • Thanks for the input. I have tried setting it up as User. Fortunately, its a standalone laptop which has only one user - 'me'. After installation it asked for service login, entered my credentials, started the service (was able to see my login in the log on as), but it still failed with the same error. I have tried this using two different connection strings, both work when run as an application, "connectionString="Dsn=sybdsn;userid=dba;databasename=db1;servername=db1;password=sql" and connectionString="Dsn=sybdb;Uid=dba;Pwd=sql".. Both work when running as an application. Any ideas? – Aaron Sep 12 '12 at 00:41