5 private links
There are few major advantages of using a database table as logging destination, such as:
It provides the ability to use all DBMS constructs to query, filter, and summarize the information available. It is as good as any other transaction table and you can use the information available in the best possible manner.
Maintenance becomes much easier with DB tables such that you can delete rows with unwanted information by simply writing a query. You can easily identify rows with unwanted data and delete these selectively. Alternatively, you can also schedule a DB job which deletes information more than 3 months old, etc. And many similar possible approaches as you would otherwise use with a database table.
There are some disadvantages of using a database table as logging destination and hence, it would not be a recommended approach if:
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
The line below tells the watcher that it has to keep looking at the path entered in the txtFile textBox. The '\' characters at the end are to make sure that the path has a directory name. Orelse there will be a problem in case the user enters something like "C:" in the text box.
Anyway... rather than add a field of type "int?" to the DataTable, I needed to add a field of type "int" as a column. Sounded simple... sort of... A fair bit of Googling and pulling together ideas from a couple of different blog posts led me to the following code.
objbulk.ColumnMappings.Add("ID", "ID");
objbulk.ColumnMappings.Add("isDeleted", "isDeleted");
objbulk.ColumnMappings.Add("Manual", "Manual");
objbulk.ColumnMappings.Add("source", "source");
if (!File.Exists(excelFilePath)) throw new FileNotFoundException(excelFilePath);