使用 InstallShield 安装和卸载SQL Server 数据库
本文主要介绍使用Installshield 进行数据库的安装和卸载,并在InstallShield 11.5 Premier Edition 和Installshield 12 Premier Edition 环境中测试通过。
1、打开“SQL Scripts view”,如图1
图1. 打开SQL Script View 视图
2、建立一个连接,假定为“MasterConnection”,按照图2和图3设置该连接的属性。
图2 建立连接
图3 设置连接的属性
3、在“MasterConnection”下,新建一个Script,属性的设置如图4,script 的内容如下:
2
3 IF NOT EXISTS (SELECT *
4
5 FROM master.dbo.sysdatabases
6
7 WHERE name = 'RelayBookkeeping')
8
9 CREATE DATABASE 'RelayBookkeeping'
10
11 GO
12
注:RelayBookkeeping是我们需要创建的数据库。
图4 新建一个Script
4、新建连接“RelayBookkeepingConnection”,按照图5设置General属性。Requirements属性的设置参照图3的一样。
图5 设置连接的属性
5、在“RelayBookkeepingConnection”下,新建你自己的数据库脚本。如图6。
图6 添加自己的数据库脚本
6、卸载程序时删除数据库。
操作方法和和新建数据库(步骤1,2,3)类似。建立一个连接,General 属性页中,设置数据库名为Master。然后添加一个Script文件,Runtime属性设置为卸载时,内容为:
DROP DATABASE RelayBookkeeping
GO
以下是在帮助里看到的,一篇是安装SQL Server的,一篇是ORACLE的。
------------------------------------------------------------------------------------------------------------------------------------------------
Creating a Sample Project that Will Create a SQL Server Catalog by Running Customized SQL Script
TASK
The following describes how to create a sample project that will create a SQL Server catalog on the target machine by running customized SQL script:
1.Create a new InstallShield project.
2.Go to the Property Manager view.
3.Create a new property named "IS_SQLSERVER_DATABASE2".
4.Go to the SQL Scripts view.
5.Create a new connection and call it "NewConnection1".
6.Click NewConnection1 in the explorer, and select the General tab.
7.Specify "TESTSQLSERVER" as the Target Server Name, and clear the Create Catalog If Absent option.
8.Select the Server Authentication option and specify "sa" as the Login ID and leave the Password field blank.
9.Click the Requirements tab.
10.Select the SQL Server check box and clear the Oracle and MySQL check boxes as the target databases.
11.Right-click NewConnection1 in the explorer, and choose New Script.
12.Rename the new script "NewScript1".
13.Select NewScript1 in the explorer, and click the Script tab.
14.Add the following script:
CREATE DATABASE [TestDB] ON (NAME = N' TestDB', FILENAME =
N'C:\Program Files\Microsoft SQL Server\MSSQL\data\testdb.mdf' ,
SIZE = 3, FILEGROWTH = 10%) LOG ON (NAME = N' TestDB_log', FILENAME
= N'C:\Program Files\Microsoft SQL Server\MSSQL\data\testdb.ldf' ,
SIZE = 1, FILEGROWTH = 10%)
COLLATE SQL_Latin1_General_CP1_CI_AS
15.Click the Runtime tab, select Run Script During Login, and then clear the other script execution options.
16.Create a new connection in the SQL Scripts view, and call it "NewConnection2".
17.Click NewConnection2 in the explorer, and select the Advanced tab.
18.From the Target Catalog Property Name box, choose IS_SQLSERVER_DATABASE2.
19.Click the General tab.
20.Specify "TESTSQLSERVER" as the Target Server Name and "TestDB" as the Catalog Name, and then clear the Create Catalog If Absent option.
21.Select the Server Authentication option and specify "sa" as the Login ID and leave the Password field blank.
22.Click the Requirements tab.
23.Select the SQL Server check box and clear the Oracle and MySQL check boxes as the target databases.
24.Right-click NewConnection2 in the explorer, and choose New Script.
25.Rename the new script "NewScript2".
26.Select NewScript2 in the explorer, and click the Script tab.
27.Add the following script:
CREATE TABLE TestTable (TestColumn1 CHAR NOT NULL PRIMARY KEY)
28.Click the Runtime tab, select Run Script During Install, and then clear the other script execution options.
------------------------------------------------------------------------------------------------------------------------------------------------
Creating a Sample Project that Will Create an Oracle Catalog by Running Customized SQL Script
TASK
The following describes how to create a sample project that will create an Oracle catalog on the target machine by running customized SQL script:
1.Create a new InstallShield project.
2.Go to the Property Manager view.
3.Create a new property named "IS_SQLSERVER_DATABASE2".
4.Go to the SQL Scripts view.
5.Create a new connection and call it "NewConnection1".
6.Click NewConnection1 in the explorer, and select the General tab.
7.Specify "//sch01jsmith.macrvision.com:1521/orcl" as the Target Server Name, and clear the Create Catalog If Absent option.
8.Select the Server Authentication option and specify "Scott" as the login ID and "Scott" as the password.
9.Click the Requirements tab.
10.Select the Oracle check box and clear the SQL Server and MySQL check boxes as the target databases.
11.Right-click NewConnection1 in the explorer, and choose New Script.
12.Rename the new script "NewScript1".
13.Select NewScript1 in the explorer, and click the Script tab.
14.Add the following script:
CREATE TABLESPACE TEST_TS LOGGING DATAFILE ' /muddle/oracle/sts/ test01.dbf ' SIZE 64K AUTOEXTEND ON NEXT 2M MAXSIZE UNLIMITED
Go
CREATE USER TEST_USER IDENTIFIED BY MYPSWD DEFAULT TABLESPACE TEST_TS QUOTA UNLIMITED on TEST_TS
Go
GRANT CONNECT TO TEST_USER
Go
GRANT DBA TO TEST_USER
Go
ALTER USER TEST_USER DEFAULT ROLE ALL
Go
15.Click the Runtime tab, select Run Script During Login, and then clear the other script execution options.
16.Create a new connection in the SQL Scripts view, and call it "NewConnection2".
17.Click NewConnection2 in the explorer, and select the Advanced tab.
18.From the Target Catalog Property Name box, choose IS_SQLSERVER_DATABASE2.
19.Click the General tab.
20.Specify "//sch01jsmith.macrvision.com:1521/orcl" as the Target Server Name and "TEST_USER" as the Catalog Name, and then clear the Create Catalog If Absent option.
21.Select the Server Authentication option and specify "TEST_USER" as the Login ID and "MYPSWD" as the password.
22.Click the Requirements tab.
23.Select the Oracle check box and clear the SQL Server and MySQL check boxes as the target databases.
24.Right-click NewConnection2 in the explorer, and choose New Script.
25.Rename the new script "NewScript2".
26.Select NewScript2 in the explorer, and click the Script tab.
27.Add the following script:
CREATE TABLE TestTable (TestColumn1 CHAR NOT NULL PRIMARY KEY)
28.Click the Runtime tab, select Run Script During Install, and then clear the other script execution options.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现