在这里完成 Inno 设置和 Pascal 新手。我想将单个.sql
文件打包到setup.exe
.
该设置可供下载,因此我无法在设置项目中嵌入任何连接字符串。.sql
该设置基本上通过运行一个简单的脚本将 .NET CLR 程序集(dll 作为十六进制流)安装到提供的 SQL 服务器数据库中
我在这里看到了关于连接到 SQL 服务器的其他帖子,但没有一个解决我的硬编码连接字符串问题或复制/实现在所有 MS 应用程序中弹出的用于建立数据库连接的通用数据连接对话框
理想情况下,连接字符串的创建应通过 MS 已发布http://archive.msdn.microsoft.com/Connection的代码的数据连接对话框来处理,但不知道如何在安装期间将其链接到弹出窗口。
如果没有(太多)努力就不可能,那么另一个选择是在 Inno Setup 中使用自定义缩减版的对话框屏幕,其中只有服务器名称\路径文本框。
用于指定是否使用 Windows 或 SQL 服务器身份验证的复选框(选择 SQL 身份验证时启用用户名/密码文本框)
此时会尝试连接并显示可用数据库的下拉列表。
我可以让服务器\实例文本框工作,但不知道如何实现 Windows 身份验证\SQL 身份验证组合框和后续操作
提示?
编辑:感谢 TLama,MS 提供的连接对话框 UI 似乎不行。我已经使用 Inno Setup 表单向导获得了“外观”方面的权利,但其中一些功能仍然让我感到困惑:
我不知道怎么做
启用/禁用
lblUser
,lblPassword
,txtUsername
,txtPassword
何时chkSQLAuth.selected
为真/假。lstDatabase
一旦文本框中有内容,启用组合框和标签txtServer
。单击. 时
lstDatabase
使用指定的凭据(连接到服务器并执行)填充组合框。"SELECT name FROM master.dbo.sysdatabases WHERE HAS_DBACCESS(name) = 1 ORDER BY name"
lstDatabase
然后在选择数据库时启用 Next 按钮。
我认为一旦完成,我应该能够弄清楚如何针对所选数据库执行我的 SQL 脚本!
[Setup]
AppName=test
AppVersion=1.0
LicenseFile=C:\Program Files (x86)\Inno Script Studio\License.rtf
CreateAppDir=False
UsePreviousGroup=False
DisableProgramGroupPage=yes
Uninstallable=no
[Files]
Source: "C:\Install Assembly.sql"; DestDir: "{tmp}"; Flags: dontcopy
[CustomMessages]
CustomForm_Caption=Connect to Database Server
CustomForm_Description=Enter the information required to connect to the database server
CustomForm_lblServer_Caption0=Server name:
CustomForm_lblAuthType_Caption0=Log on credentials
CustomForm_lblUser_Caption0=User name:
CustomForm_lblPassword_Caption0=Password:
CustomForm_lblDatabase_Caption0=Database:
CustomForm_chkSQLAuth_Caption0=Use SQL Server Authentication
CustomForm_chkWindowsAuth_Caption0=Use Windows Authentication
[Code]
var
lblServer: TLabel;
lblAuthType: TLabel;
lblUser: TLabel;
lblPassword: TLabel;
lblDatabase: TLabel;
chkSQLAuth: TRadioButton;
txtServer: TEdit;
chkWindowsAuth: TRadioButton;
txtUsername: TEdit;
txtPassword: TPasswordEdit;
lstDatabase: TComboBox;
var
Page: TWizardPage;
{ CustomForm_Activate }
procedure CustomForm_Activate(Page: TWizardPage);
begin
// enter code here...
end;
{ CustomForm_ShouldSkipPage }
function CustomForm_ShouldSkipPage(Page: TWizardPage): Boolean;
begin
Result := False;
end;
{ CustomForm_BackButtonClick }
function CustomForm_BackButtonClick(Page: TWizardPage): Boolean;
begin
Result := True;
end;
{ CustomForm_NextkButtonClick }
function CustomForm_NextButtonClick(Page: TWizardPage): Boolean;
begin
Result := True;
end;
{ CustomForm_CancelButtonClick }
procedure CustomForm_CancelButtonClick(Page: TWizardPage; var Cancel, Confirm: Boolean);
begin
// enter code here...
end;
{ CustomForm_CreatePage }
function CustomForm_CreatePage(PreviousPageId: Integer): Integer;
begin
Page := CreateCustomPage(
PreviousPageId,
ExpandConstant('{cm:CustomForm_Caption}'),
ExpandConstant('{cm:CustomForm_Description}')
);
{ lblServer }
lblServer := TLabel.Create(Page);
with lblServer do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:CustomForm_lblServer_Caption0}');
Left := ScaleX(24);
Top := ScaleY(8);
Width := ScaleX(68);
Height := ScaleY(13);
end;
{ txtServer }
txtServer := TEdit.Create(Page);
with txtServer do
begin
Parent := Page.Surface;
Left := ScaleX(112);
Top := ScaleY(8);
Width := ScaleX(273);
Height := ScaleY(21);
TabOrder := 0;
end;
{ lblAuthType }
lblAuthType := TLabel.Create(Page);
with lblAuthType do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:CustomForm_lblAuthType_Caption0}');
Left := ScaleX(24);
Top := ScaleY(48);
Width := ScaleX(87);
Height := ScaleY(13);
end;
{ chkWindowsAuth }
chkWindowsAuth := TRadioButton.Create(Page);
with chkWindowsAuth do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:CustomForm_chkWindowsAuth_Caption0}');
Left := ScaleX(32);
Top := ScaleY(64);
Width := ScaleX(177);
Height := ScaleY(17);
Checked := True;
TabOrder := 1;
TabStop := True;
end;
{ chkSQLAuth }
chkSQLAuth := TRadioButton.Create(Page);
with chkSQLAuth do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:CustomForm_chkSQLAuth_Caption0}');
Left := ScaleX(32);
Top := ScaleY(84);
Width := ScaleX(185);
Height := ScaleY(17);
TabOrder := 2;
end;
{ lblUser }
lblUser := TLabel.Create(Page);
with lblUser do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:CustomForm_lblUser_Caption0}');
Left := ScaleX(56);
Top := ScaleY(104);
Width := ScaleX(58);
Height := ScaleY(13);
Enabled := False;
end;
{ lblPassword }
lblPassword := TLabel.Create(Page);
with lblPassword do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:CustomForm_lblPassword_Caption0}');
Left := ScaleX(56);
Top := ScaleY(128);
Width := ScaleX(53);
Height := ScaleY(13);
Enabled := False;
end;
{ txtUsername }
txtUsername := TEdit.Create(Page);
with txtUsername do
begin
Parent := Page.Surface;
Left := ScaleX(120);
Top := ScaleY(104);
Width := ScaleX(241);
Height := ScaleY(21);
Enabled := False;
TabOrder := 3;
end;
{ txtPassword }
txtPassword := TPasswordEdit.Create(Page);
with txtPassword do
begin
Parent := Page.Surface;
Left := ScaleX(120);
Top := ScaleY(128);
Width := ScaleX(241);
Height := ScaleY(21);
Enabled := False;
TabOrder := 4;
end;
{ lblDatabase }
lblDatabase := TLabel.Create(Page);
with lblDatabase do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:CustomForm_lblDatabase_Caption0}');
Left := ScaleX(56);
Top := ScaleY(168);
Width := ScaleX(53);
Height := ScaleY(13);
end;
{ lstDatabase }
lstDatabase := TComboBox.Create(Page);
with lstDatabase do
begin
Parent := Page.Surface;
Left := ScaleX(120);
Top := ScaleY(168);
Width := ScaleX(145);
Height := ScaleY(21);
TabOrder := 5;
end;
with Page do
begin
OnActivate := @CustomForm_Activate;
OnShouldSkipPage := @CustomForm_ShouldSkipPage;
OnBackButtonClick := @CustomForm_BackButtonClick;
OnNextButtonClick := @CustomForm_NextButtonClick;
OnCancelButtonClick := @CustomForm_CancelButtonClick;
end;
Result := Page.ID;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = Page.ID then
WizardForm.NextButton.Enabled := False;
end;
{ CustomForm_InitializeWizard }
procedure InitializeWizard();
begin
CustomForm_CreatePage(wpWelcome);
end;