B ackup MSSQL DB & save to disk or email, user friendly app

H ey hey, One more exciting B Log;)

To continue the tradition of breaking promise, which I made in my last post about; “Giving you a small visual studio solution, using extJS4 as front end which consumes web services”. Well, This post does not contain what I promised for, but has something interesting and useful 🙂

Why I am sharing it?

Well, I think, every bit of sharing knowledge and expertise is “better than keeping it just to self”. You expand your knowledge-base by sharing it.

So, In the spirit of sharing and continued tradition of broken promise;

What I am sharing?

Backup and email the sql database

Here, I present you a with very small, lightweight c# win-forms application; Which uses the windows authentication to login(As currently, logged in user to windows) to the localhost database, connects to the default instance of SQL SERVER (MSSQLSERVER)

This utility is mainly used to backup the MSSQL database and save it to disk and to stretch things a little more, it will send zipped backup as attachment to an email, using your Hotmail or Gmail account. Code as supplied, DOES NOT CONTAIN logic to store PASSWORD OR EMAIL IN ANY FORM.

Who benefits from this application?

Developer, Why? because as a developer, I personally felt the task of taking database backup; using management studio as tedious and slightly overkill (I know this is not something that you do everyday, but you feel that you are dealing with so many options and dialogs when you just wanted to “Take a full database backup”)

May be not right for DBA, Why? because DBA would like more options with backups. And as “Rule of simplicity”, I choose to not cater for other options (Doesn’t mean, I am stopping you from doing it :p , be brave and explore)

Everyone else May be/May not be, because no one else cares about database, and this application is too techie for everyone else (tell me about it)

Nuts and bolts of this application?

Language used; c#, winforms

Uses T-SQL to execute Backup command on the selected database:

[sourcecode language=”csharp” ]
These driving forces then cause our body to deliver a healthy erection. tadalafil 40mg Erection issue is observed when there is lack of blood supply to the penile region can be a major cause which can be due to the physiological and psychological factors that slows the flow of blood in tadalafil canadian pharmacy loved that the penile. Tongkat Ali: prescription for ordering viagra It is a tropical aphrodisiac which originates in Malaysia. Booster capsules are viagra free samples the best herbal supplements to prevent soft erection. try
{
using (SqlConnection sqlConn = new SqlConnection(cnst_default_connectionstring))
{
string tSqlString = String.Format(@”BACKUP DATABASE [{0}] TO DISK = N'{1}’ WITH NOFORMAT, INIT, NAME = N'{0}-Full Database Backup’, SKIP, NOREWIND, NOUNLOAD, STATS = 10″, _selectedDatabase, _selectedBackupPath);
SqlCommand sqlCommand = new SqlCommand(tSqlString) { Connection = sqlConn };
sqlConn.Open();
sqlCommand.ExecuteNonQuery();
}
}
[/sourcecode]

and Uses System.IO.Compression to compress the backup,
and Uses System.Net.Mail and SmtpClient to attach compressed backup and send email

For now, you can only use “Gmail” or “Hotmail/live” account to use as from email account.

SQLBackupAndEmail – Source code

SQLBackupAndEmail – Demo application

If you have any questions, I am more than happy to answer them 🙂

I am not making another promise to break it, but, All, I can say is “Watch this space !!”

V alidate your DBML file for stored proc and function existence

Back again, Hope you are all doing just fine and are well over the “Royal Wedding”.

As my last B log note to self, here is more techie post.

If you are a .Net developer, this post is more useful to you.

How would you validate your DBML file for any invalid stored proc or function referenced in it? MANUALLY???? Naaah……

Yeas, that’s what I thought and my brain acknowledged “Naaah…” and I wrote a very simple C# winforms application which takes DBML file as input. Once you select DBML file, it reads and populates the grid with stored procedure and function name that exist in DBML file. You can select another DBML file, and the content of new DBML file will be appended into the grid view (This way you can validate multiple DBML files’ content).

User requires to know the ip address of database, username and password that will be used to connect to SQL Server. You can tick “Remember” to remember the IP address, username and database name (I thought, storing database password was bad idea). and obviously, your IP address should have access to the SQL Server (i.e. if your SQL Server has firewall setup, your IP address needs to be in “Allowed” list)
These tablets relax the muscles that are traumatized because of injuries incurred can be rehabilitated and brought back to normal with the clinical massage sessions performed. cialis price online We come across thousands of men who are suffering from the erectile discount viagra dysfunction of male reproductive system. Aurogra Tablets – The reputed Aurochem laboratories manufactured Aurogra tablets by using key ingredient of viagra brand online and cheap kamagra . Psychological issues include prolonged stress, long-term depression, anticipatory anxiety, and relationship issues. energyhealingforeveryone.com cheap levitra
CrossCheckDBML

I have posted this article on CodeProject too. But I decided to share it here as well.

You can use this application or source code for personal use or for learning purpose. There is small usage of “ConfiguarationManager” too.

Any or all feedback, comments and criticism are most welcome. I will try to act upon feedback/comments received.

Note to self: Next post will be about experience dealing with “Telerik”, “Aspose” and “SpreadsheetGear” regarding their support.