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.

4

2 回答 2

3

看起来您正在使用 DSN 连接到 SQL Anywhere。

首先,确保您已将其配置为系统 DSN。然后,验证您使用的是 TCP/IP 连接协议(ODBC 管理 -> 选择系统 DSN 选项卡 -> 在列表中选择 DSN -> 单击配置 -> 转到网络选项卡)并且不是共享内存。

尝试连接到 SQL Anywhere 数据库服务器的 Win 服务无法使用共享内存。我怀疑这是问题所在,因为您可以使用相同的连接字符串从桌面应用程序进行连接。

完成这项工作的一种方法是将 SQL Anywhere 数据库作为网络服务器启动(开始 -> 所有程序 -> Sql Anywhere 12(或 11,取决于您的设置)-> SQL Anywhere -> 网络服务器。

这应该运行 dbsvr12.exe,它将开始侦听 TCP 端口上的连接。

然后,将Links=tcpipHost=localhost添加到您的 Win 服务连接字符串并试一试!

于 2012-11-22T07:52:47.540 回答
0

请注意,简单的 win 应用程序正在使用来自登录用户的凭据运行,而 Windows 服务正在系统帐户上运行(在您的情况下)。您有两个选择,更改连接字符串以连接特定用户(如果您现在使用受信任的连接)或将 Windows 服务登录用户更改为您的用户。

于 2012-09-10T06:05:02.517 回答