0

我的 c# 服务有问题。我首先将我的程序作为控制台应用程序进行了测试,一切顺利。完成测试后,我设置了一项服务并在我的 PC 上安装了该服务。在服务中,我想从 SQL 服务器进行查询。代码片段可以在这里找到:

// Create the Command and Parameter objects.
sQuery = "select count(*) " + sWhere;
eventLog.WriteEntry("Datasets for archive transfer will be calculated by" + sQuery, EventLogEntryType.Information);

commandSelect = new SqlCommand(sQuery, connectionSQL);
connectionSQL.Open();

reader = commandSelect.ExecuteReader();

但是每次涉及到 commandSelect.ExecuteReader() 时,我都会收到一个错误,即没有打开的连接。我添加了很多日志以查看连接是否已关闭,还添加了显式 open() 命令,但我无法启动并运行它。有人对此有任何想法吗?在这一点上,控制台程序和 da 服务之间的巨大而明显的秘密区别是什么?

谢谢马蒂亚斯

4

0 回答 0