Inno Setup: dodaj GUI, aby połączyć się z SQL
Ukończ tutaj Inno Setup i Pascala. Chcę spakować singiel.sql
plik wewnątrz asetup.exe
.
Konfiguracja będzie dostępna do pobrania, więc nie mogę osadzić żadnych łańcuchów połączeń w projekcie instalacji. Instalator zasadniczo instaluje zespół .NET CLR (dll jako strumień heksadecymalny) do dostarczonej bazy danych serwera SQL, uruchamiając prosty.sql
scenariusz
Widziałem inne posty tutaj dotyczące łączenia się z serwerem SQL, ale żaden z nich nie dotyczy mojego problemu z zakodowanym na stałe łańcuchem połączenia lub replikacji / implementacji ogólnego okna dialogowego połączenia danych, które pojawia się we wszystkich aplikacjach MS do tworzenia połączenia DB
W idealnej sytuacji utworzenie ciągu połączenia powinno być obsługiwane za pomocą okna dialogowego połączenia danych, dla którego MS wydał kodhttp://archive.msdn.microsoft.com/Connection ale nie mam pojęcia, jak to połączyć, aby wyskoczyć podczas instalacji.
Jeśli nie jest to możliwe bez (zbyt dużego) wysiłku, kolejną opcją byłoby posiadanie niestandardowej wersji okna dialogowego w programie Inno Setup z jedynie polem tekstowym nazwy serwera.
Pole wyboru określające, czy używać uwierzytelniania systemu Windows lub serwera SQL (pola tekstowe nazwa użytkownika / hasło są włączane po wybraniu uwierzytelniania SQL)
W którym momencie zostanie nawiązane połączenie i pojawi się lista rozwijana dostępnych baz danych.
Mogę uzyskać działające pole tekstowe serwera, ale nie mam pojęcia, jak zaimplementować uwierzytelnianie systemu Windows Pole kombi uwierzytelniania SQL i kolejne działania
Porady?
edit: Dzięki TLama, interfejs użytkownika dostarczony przez MS wygląda na to, że nie ma wyjścia. Dostałem aspekt „wyglądu” za pomocą kreatora formularza Inno Setup, ale niektóre funkcje wciąż mnie zaskakują:
Nie mam pojęcia jak
włącz / wyłączlblUser
, lblPassword
, txtUsername
, txtPassword
gdychkSQLAuth.selected
jest prawdą / fałszem.
włączlstDatabase
pole kombi i etykieta po zawartości wtxtServer
pole tekstowe.
zaludniaćlstDatabase
pole kombi przy użyciu określonych poświadczeń (połącz się z serwerem i uruchom"SELECT name FROM master.dbo.sysdatabases WHERE HAS_DBACCESS(name) = 1 ORDER BY name"
) po kliknięciulstDatabase
.
Następnie włącz przycisk Dalej, gdy wybrana zostanie baza danych.
Myślę, że kiedy to zrobię, będę mógł dowiedzieć się, jak wykonać mój skrypt SQL na wybranej bazie danych!
[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;