As you may know, I’ve recently tweaked someone’s C# code to make it work the way I want. That post can be found here. I am pleased to say that it work perfectly on my laptop but when I loaded it on the server to be executed, I got the error:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.Office.Interop.Excel, Version=126.96.36.199, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. The system cannot find the file specified.
I don’t know if I mentioned this or not but I have a SQL 2005 instance that has over 260 databases. A few weeks back, I wrote a store procedure to backup all the databases every Sunday. Nothing wrong with the stored procedure except that the entire run time took around 8hours. That’s 8 hours of the system being hammered while users are querying against the database and ongoing bulk insert from some monitoring system that no one seem to have documentation about. Not only that, this is just 1/5 SQL instances running on one server.
The following code will delete files after xx amount of days.
DirectoryInfo di = new DirectoryInfo(GetResultFolder);
FileInfo logFile = di.GetFiles(GetResultFile+"*.txt").OrderByDescending(log => log.LastWriteTime).Skip(2).FirstOrDefault();
The key to this section is the .Skip(x).FirstOrDefault(); statement.
The other day, a co-worker showed me some C# code that included Lambdas Expression and I read it some other books as well. I scoffed at it because who need all that confusing syntax?! Well I sat down the other day and thought it over and it was pretty damn cool. The syntax might be confusing as heck, at first, but if you managed to get use it to it, it can shorten length code.
I decided to take it upon myself to learn more about Lambda along with it’s expression and statement block. I decided to start out easy, writing a short program that will find the prime number from an array.
If you are planning to write a SMO application to connect/communicate with SQL server, you will need to add the following references before you can make use of:
The location of the Dlls for SQL 2008 R2 is:
C:Program FilesMicrosoft SQL Server100SDKAssemblies
You will need to add the following dlls: