Extracting Attachments from Selected Emails

This is a continuation of the article “Automating the Process of Extracting *.sql Attachments from Emails and Executing them on a set of SQL Server Databases”. If you have not read that article, I recommend you do that before proceeding further.

The Problem

Find a way to extract all attachments from selected emails into a selected folder on hard-drive.

The Solution

  1. Open Microsoft Outlook.
  2. Click Tools > Macro > Visual Basic Editor (or press Alt+F11) to open the VBA Editor. … Read the full article »

Automating the Process of Extracting *.sql Attachments from Emails and Executing them on a set of SQL Server Databases

Recently I was off on a long leave from my work. After returning to office, I found that there are so many emails accumulated in my inbox, and many of them contained SQL script files to be executed on my local SQL Server test databases. Extracting each file into a folder and then executing each of these files (*.sql files) on each database was just like the task I always hate. There were some hundred of these attachments, and each file had to be executed on about 6 databases. So if I do everything manually, it will take me days to finish this.

So I set off for making a script that will automate this. … Read the full article »

Persisting the values of Controls on your Form

This is a common situation and a frequently asked question on various technical forums and websites.

  • I want the controls to retain values after the form/application is closed and opened again.
  • I want to persist the values in textbox after my application is restarted.
  • I want the form to open exactly how I left it the last time.
  • I want the form to remember its state and persist it. etc.etc.
  • Today we will see how to resolve this problem in our VB.NET applications. … Read the full article »

Insert a String / Text in Large File using VB.NET


If you have been a VB programmer for a while you know that inserting strings in large files is a pain.

The most usual way is to read the whole file into a variable in memory, insert your string in that variable, and then write the whole file back to disk. This works OK for small files. But is a problem with extraordinarily large files, since it would involve large memory overheads. … Read the full article »

Stored Procedure to Benchmark Performance of two SQL Statements or SP

Many a times we feel a need to quickly compare two SQL queries or Stored Procedure performance to judge which one of the two is performing better.

The longer (better) way is to properly analyze the execution plan and manually fine-tune it. But that takes a lot of time. The shorter way is to just run those two queries and compare the time taken. But after running them for the first time, the result is not always accurate because the results are displayed from cache whenever possible (i.e. second time onwards).

The following stored procedure can be used to compare the performance of two queries/SPs. … Read the full article »

Add Undo/Redo or Back/Forward Functionality to your Application

I have often seen people asking on various forums how to implement Undo/Redo functionality or Back/Forward functionality in their applications. Typically an undo/redo in text-editors or back/forward in file/folder explorers or customized webbrowsers are common examples.

So today we will see how to develop a class to implement such functionality. … Read the full article »

The IsNot Operator in VB.NET

One of the most underused operator in VB.NET is the IsNot operator. That’s because there was really no significant use of introducing this operator. All was going well without this operator too. I find that many experienced programmers are still unaware of the existence of this operator in VB.NET.

The old way of doing things was:

If Not object1 Is object2 Then whatever

… Read the full article »