我创建了一个窗口服务,我使用窗体来测试它。当我以窗口形式测试它工作正常但是当我将它作为服务应用时它不起作用。
OleDbConnection MyConnection;
DataSet Data;
OleDbDataAdapter MyCommand;
using (MyConnection = new System.Data.OleDb.OleDbConnection(@"provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName +
";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';"))
{
MyCommand = new OleDbDataAdapter("select * from [" + GetSheetName(fileName) + "$]", MyConnection);
Data = new DataSet();
MyCommand.Fill(Data);
MyConnection.Close();
if (Data.Tables[0].Rows.Count == 1)
{
return;
}
}