SQLDMO Create Sql server Database C# code
Sample code to create an sql server Database using SQLDMO Library.
Add 'SQLDMO.dll' refference to your Project
public bool CreateDb(string serverName, string Uid, string Pwd, string dbName)
{
bool result = true;
SQLDMO.SQLServer gSQLServerDMO = new SQLDMO.SQLServer();
SQLDMO.Database nDatabase = new SQLDMO.Database();
SQLDMO.DBFile nDBFileData = new SQLDMO.DBFile();
SQLDMO.LogFile nLogFile = new SQLDMO.LogFile();
try
{
gSQLServerDMO.LoginSecure = true;
gSQLServerDMO.Connect(serverName, Uid, Pwd);
nDatabase.Name = dbName;
nDBFileData.Name = dbName;
nDBFileData.PhysicalName = gSQLServerDMO.Registry.SQLDataRoot + "\\DATA\\" + dbName + "_Data.mdf";
nDBFileData.PrimaryFile = true;
nDBFileData.Size = 2;
nDBFileData.FileGrowthType = SQLDMO.SQLDMO_GROWTH_TYPE.SQLDMOGrowth_MB;
nDBFileData.FileGrowth = 1;
//Add the DBFile object
nDatabase.FileGroups.Item("PRIMARY").DBFiles.Add(nDBFileData);
//
nLogFile.Name = dbName + "Log";
nLogFile.PhysicalName = gSQLServerDMO.Registry.SQLDataRoot + "\\DATA\\" + dbName + "_Log.ldf";
nLogFile.Size = 2;
nDatabase.TransactionLog.LogFiles.Add(nLogFile);
gSQLServerDMO.Databases.Add(nDatabase);
MessageBox.Show("Database Created Sucessfully);
gSQLServerDMO.DisConnect();
}
catch (Exception SQLDBException)
{
MessageBox.Show(SQLDBException.Message);
result = false;
}
finally
{
}
return (result);
}

This code is very nice to take back...
But i'm unable to add the 'SQLDMO.dll' to my project.
can you tellme the way to install & add ''SQLDMO.dll' to my project to take backup...