Hi, I am doing a window service application using C#. I wants to select many columns from many table and print into text file. Below is my coding:
protected override void OnStart(string[] args)
{
try
{
base.OnStart(args);
Access_Db.OpenTransaction();
Access_Db.BeginTransaction();
DataTable dtPartNo = new DataTable();
SQLStr = "SELECT IDTbl.ModelID,WIPTbl.WIP FROM IDTbl,WIPTbl";
dtPartNo = AccessDb_Cmd.RetrieveData(SQLStr, Access_Db).Tables[0];
FileStream fs = new FileStream("c:\\AccessoriesPacking.txt", FileMode.Append, FileAccess.Write, FileShare.Write);
fs.Close();
StreamWriter sw = new StreamWriter("c:\\AccessoriesPacking.txt", true, Encoding.ASCII);
sw.WriteLine(dtPartNo );
sw.Close();
}
catch (Exception ex)
{
// event
}
finally
{
Access_Db.CloseTransaction();
}
}
After i build the program, there is no error but it doesn't create a text file and print anything in the expected location, how comes like that?