Need reference code for SMO in C# SQL Server 2008 – Education Career Blog

I googled but cannot find proper simple code for using backup database full and restore the backup, using defaults by using C#.

I am using C# Visual Studio 2008 and SQL Server 2008 R2 evalution but I guess SQL Server 2005 and C# will work too.

The Microsoft site doesn’t have code regarding it, it only show description of Microsoft.SqlServer.Management.Smo Namespace……

,

MSDN has a topic Getting Started in SMO that covers a lot of ground – there’s also a topic called Programming Specific Tasks which shows how to do certain common tasks in C# with SMO.

And there’s a whole series of Getting Started with SMO in SQL Server 2005 which still very much applies to the 2008 and 2008 R2 versions of SQL Server.

Here’s another Getting started with SQL Server Management Objects (SMO) article to get you up to speed.

,

Here is an example with VB.NET
http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.restore.aspx
You can use a converter to get C#:
http://www.developerfusion.com/tools/convert/csharp-to-vb/

Leave a Comment