string connStr=String.Format("data source={0};user id={1};password={2};persist security info=false;packet size=4096",Context.Parameters["server"],Context.Parameters["user"],Context.Parameters["pwd"]);
//create database following the db name
//ExecuteSql(connStr,Context.Parameters["dbname"],"CREATE DATABASE "+Context.Parameters["dbname"]);
string strSql;
strSql="IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = '" + Context.Parameters["dbname"] + "') DROP DATABASE [" + Context.Parameters["dbname"] + "]";
ExecuteSql(connStr,Context.Parameters["dbname"],strSql);
strSql="CREATE DATABASE "+Context.Parameters["dbname"];
ExecuteSql(connStr,Context.Parameters["dbname"],strSql);
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
AddDBTable(this.Context.Parameters["dbname"]);
}
8、再添加一个新项目,(选择添加到解决方案中)->项目类型为安装项目->命名为DBCustomAction Installer
9、选择应用程序文件夹->添加->项目输出->主输出
10、在方案资源管理器中->右键安装项目(DBCustomAction Installer)->视图->用户界面
11、选中启动结点->添加对话框->文本A
12、选动文本框A->右键->上移一直到最顶端
13、选择文本框A属性->修改BannerText,(Specify Database Name)
14、修改BodyText(This dialog allows you to specify the name of the database to be created on the database server. )
15、修改EditLabel1(Name of DB),修改Edit1Porperty(CUSTOMTEXTA1),将其他Edit2,3,4的Edit(2,3,4)Visible属性设为false;
16、在方案资源管理器中->右键安装项目(DBCustomAction Installer)->视图->自定义操作
17、选中安装结点->添加->双击应用程序文件夹->主输出来自DBCustomAction(活动)->右键属性->CustomActiveData属性修改为/dbname=[CUSTOMTEXTA1]
18、编译生成,OK!