Saturday, February 13, 2010

Installing Sql-server 2005 express edition using C#.net

In the previous post i had discussed how to install sql-server 2005 express using command prompt. Today I am going to discuss how to install it using C#.net code. The code for it is as follows:


using System.Diagnostics;

void InstallExpress()
{
Process p = new Process();
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = Application.StartupPath.Trim() + @"\SqlServer2005 Express\SQLEXPR.EXE";
           
            psi.Arguments = "/qn username=\"CustomerUsername\" companyname=\"OurCompany\" addlocal=ALL  disablenetworkprotocols=\"0\" instancename=\"MyInstance\" SECURITYMODE=\"SQL\" SAPWD=\"mypassword\"";

            p.StartInfo = psi;
            p.Start();
}

This is quite simple and easy to implement. Here we have created a process that would run the commands to install the sql-server 2005 express in silent mode.

3 comments:

  1. Thanks dude for the update... it really helped me... i got stuck in it... u saved me... thanks a ton !!!

    ReplyDelete
  2. the problem of data corruption in the files of specified format can be fixed by the file magic sql server will not start utility

    ReplyDelete
  3. Would you tell me how to install sql server database in other system using c# installation file.my project is ready but i don't know how to install database in other system with my c# project.

    ReplyDelete

Comments to this post

LinkWithin

Related Posts with Thumbnails