与Windows Service .Net 3.5的SQL连接问题 [英] Issue in SQL connectivity with Windows Service .Net 3.5
问题描述
大家好,
我已经在C#.net 3.5中创建了Windows服务.该服务建立与SQL Server 2005的连接,并执行一些存储过程.
托管服务的服务器和数据库服务器位于远程.
问题是,服务无法打开SQL连接.但是,使用相同的连接字符串,我可以使用控制台应用程序连接SQL Server.
我无法解决问题.
任何解决方案或建议都将非常有帮助.
提前谢谢.
问候,
Sharath
Hi All,
I have created a Windows Service in C# .net 3.5. The service establishes connection with SQL server 2005 and execute few stored procedures.
The server where the service is hosted and the database server are remotely located.
The issue is, the service is failing to open the SQL connection. However, using the same connection string, I am able to connect the SQL Server using a Console Application.
I am unable to figure out the issue.
Any resolutions or suggestions would be really very helpful.
Thanks in advance.
Regards,
Sharath
推荐答案
对象引用未设置为对象的实例
当您尝试使用属性或调用对象的方法为null时,会发生此错误.更多详细信息:此处 [
Object reference not set to an instance of an object
This error happens when you try to use a property or call a method of an object that is null. More details: here[^]
A simple use of Visual studio DEBUGGER can tell you the object because of which it is happening. Just look at the stack trace and put a debugger on that line. Check the objects of that line and see if any one is null and you are trying to use that objects property. Handle the same.
这篇关于与Windows Service .Net 3.5的SQL连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!