Nie sądzę, że możesz mieć całkowicie ogólną formę, ponieważ dla różnych serwerów możesz potrzebować jednego ciągu połączenia lub nazwy serwera i (opcjonalnego) portu; dla niektórych serwerów będziesz używał uwierzytelniania systemu, dla innych - tupty hasła użytkownika.
Powiedziawszy, że dam ci mały skrypt demonstracyjny Inno, który prosi o nazwę serwera i port, nazwę użytkownika i hasło, następnie wykonuje kilka testów, a następnie wykonuje aplikację, która jest wyodrębniana (przez kod) do katalogu tymczasowego i zostaną usunięte przez instalatora. Możesz użyć tego jako punktu wyjścia dla swoich skryptów. Mając kilka takich fragmentów, a włączenie ich w skryptach jak konieczne będzie prawdopodobnie wszystko, czego potrzebujesz:
[Setup]
AppID=DBUpdateTest
AppName=Test
AppVerName=Test 0.1
AppPublisher=My Company, Inc.
DefaultDirName={pf}\Test
DefaultGroupName=Test
DisableDirPage=yes
DisableProgramGroupPage=yes
OutputBaseFilename=setup
PrivilegesRequired=none
[Files]
Source: "isql.exe"; DestDir: "{tmp}"; Flags: dontcopy
Source: "update_V42.sql"; DestDir: "{tmp}"; Flags: dontcopy
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Code]
var
DBPage: TInputQueryWizardPage;
procedure InitializeWizard;
begin
DBPage := CreateInputQueryPage(wpReady,
'Database Connection Information', 'Which database is to be updated?',
'Please specify the server and the connection credentials, then click Next.');
DBPage.Add('Server:', False);
DBPage.Add('Port:', False);
DBPage.Add('User name:', False);
DBPage.Add('Password:', True);
DBPage.Values[0] := GetPreviousData('Server', '');
DBPage.Values[1] := GetPreviousData('Port', '');
DBPage.Values[2] := GetPreviousData('UserName', '');
DBPage.Values[3] := GetPreviousData('Password', '');
end;
procedure RegisterPreviousData(PreviousDataKey: Integer);
begin
SetPreviousData(PreviousDataKey, 'Server', DBPage.Values[0]);
SetPreviousData(PreviousDataKey, 'Port', DBPage.Values[1]);
SetPreviousData(PreviousDataKey, 'UserName', DBPage.Values[2]);
SetPreviousData(PreviousDataKey, 'Password', DBPage.Values[3]);
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
ResultCode: Integer;
begin
Result := True;
if CurPageID = DBPage.ID then begin
if DBPage.Values[0] = '' then begin
MsgBox('You must enter the server name or address.', mbError, MB_OK);
Result := False;
end else if DBPage.Values[2] = '' then begin
MsgBox('You must enter the user name.', mbError, MB_OK);
Result := False;
end else if DBPage.Values[3] = '' then begin
MsgBox('You must enter the user password.', mbError, MB_OK);
Result := False;
end else begin
ExtractTemporaryFile('isql.exe');
ExtractTemporaryFile('update_V42.sql');
if Exec(ExpandConstant('{tmp}') + '\isql.exe', '--user ' + DBPage.Values[2]
+ ' --password ' + DBPage.Values[3] + ' --database ' + DBPage.Values[0]
+ ':foo --script update_V42.sql', '',
SW_HIDE, ewWaitUntilTerminated, ResultCode)
then begin
// check ResultCode and set Result accordingly
Result := ResultCode = 0;
end else begin
MsgBox('Database update failed:'#10#10 + SysErrorMessage(ResultCode),
mbError, MB_OK);
Result := False;
end;
end;
end;
end;
Uwaga: Nie w pełni przetestowane, więc nie może być więcej kodu niezbędne do prawidłowego czyste wszystko w górę. Obsługa błędów zdecydowanie nie istnieje!
To na pewno możliwe, ale bez dalszych informacji trudno jest udzielić sensownej odpowiedzi. Jakie jest Twoje pytanie? Czy już próbowałeś to zrobić? Jaka baza danych? Proszę wyjaśnić ... – mghie
cóż, chodzi o to, żeby mieć ogólną formę - szczegóły powyżej .. – ofer