This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Update XML File on SQLServerSelectLogin dialog screen
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 07, 2011
07:28 AM
Update XML File on SQLServerSelectLogin dialog screen
Hi folks... I've spent a full day going through the forum but am unable to come to a conclusion.
I am a C# developer and have taken over the development of a project.
The project was bundled up by the previous developer using InstallShield but this my first encounter with it.
I will have to do some serious reading up but at the minute the project is ready to be installed on some client machines for beta testing and I have a showstopper basically which is preventing me from preparing the application for release.
There appears to be code in place in the installscript for what I need to do but I do not know if it is correct or needs tweaking.
Basically the task at hand is to :
1) Allow the user to select an SQL Server instance from the dropdown on the SQL Dialog Window.. this works fine and the connection is tested as successful or not successfull.
2) If successful, I want my 'ApplicationConfiguration.xml' file to have a connection string added for the server they selected in the dropdown ... or... amend a 'base' connection string in the xml file.... whichever is easiest.
I will attach the current code below.. I notice there is a 'ChangeXML.exe' file ... which I dont have in my project... as mentioned above Im completely new to this but hopefully the attached code will speak for itself.
Hopefully this code may also help someone else as I seen some similar issues througout the forum:)
Many Thanks
File 1: Setup.rul
//===========================================================================
//
// File Name: Setup.rul
//
// Description: Blank setup main script file
//
// Comments: Blank setup is an empty setup project. If you want to
// create a new project via. step-by step instructions use the
// Project Assistant.
//
//===========================================================================
// Included header files ----------------------------------------------------
#include "ifx.h";
// variables storing sql server connection string configuration
STRING m_sConnection, m_sServer, m_sDB, m_sUser, m_sPassword;
STRING m_sConnection2, m_sServer2, m_sDB2, m_sUser2, m_sPassword2;
BOOL m_bAuthentication;
BOOL m_bAuthentication2;
#include "featureevents.rul"
#include "auxiliary.rul"
#include "utils.rul"
#include "sql.rul"
//---------------------------------------------------------------------------
// OnSQLServerInitialize
//
// The OnSQLServerInitialize event is called by OnFirstUIBefore to
// establish any connections necessary for SQL Server support.
//
// This function will initialize the SQL Server runtime, and attempt to
// make any necessary SQL Server connections, displaying a login dialog
// for each one.
//
// Parameter nBtn indicates whether NEXT or BACK was the result of the
// previously displayed dialog. It is for information purposes only.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function number OnSQLServerInitialize( nBtn )
number nResult, nErrorCode, nErrorLine;
number nCount;
string szSettingsFile;
string szConnection;
string szServer, szDB, szUser, szPassword;
string szMessage;
string szError[MAX_PATH];
string szKey;
string szDatabaseServer[MAX_PATH];
string szScriptName;
LIST listConnections;
BOOL bWinLogin;
BOOL bNext;
begin
//First initialize SQL Server runtime
szSettingsFile = SUPPORTDIR ^ "SQLRT.ini";
SQLRTInitialize( szSettingsFile );
//Get the names of all the necessary connections
listConnections = SQLRTGetConnections();
ListGetFirstString (listConnections, szConnection);
nCount = 0;
//determine if NEXT or BACK will be returned
//if there are no connections to make
if( nBtn != BACK ) then
bNext = TRUE;
else
bNext = FALSE;
//start at end if going BACK
while (ISERR_SUCCESS = ListGetNextString( listConnections, szConnection ) );
nCount++;
endwhile;
endif;
// Login for each connection
while (nResult = ISERR_SUCCESS)
//Get Default values for connection
SQLRTGetConnectionInfo( szConnection, szServer, szDB, szUser, szPassword );
bWinLogin = SQLRTGetConnectionAuthentication( szConnection );
// Display login dialog (without connection name)
// COMMENT OUT TO SWAP DIALOGS
nResult = SQLServerSelectLogin( szServer, szUser, szPassword, bWinLogin );
// Display login dialog (with connection name)
// UNCOMMENT TO SWAP DIALOGS
// nResult = SQLServerSelectLoginEx( szConnection, szServer, szUser, szPassword, bWinLogin );
if( nResult = NEXT ) then
//store data in case we need it again
SQLRTPutConnectionInfo( szConnection, szServer, szUser, szPassword );
//try connection
nResult = SQLRTConnect2( szConnection, szServer, bWinLogin, szUser, szPassword, szDatabaseServer );
if( nResult < ISERR_SUCCESS ) then
SQLRTGetLastError( szError );
if (nResult = SQL_ERROR_LOGIN_FAILED) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_LOGIN_FAILED ), szDatabaseServer, szError);
MessageBox( szMessage, MB_OK );
//Show same login dialog again
nResult = ListCurrentString(listConnections, szConnection);
elseif (nResult = SQL_ERROR_VERSION_MISSING) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_VERSION_MISSING ), szDatabaseServer);
MessageBox( szMessage, MB_OK );
//Show same login dialog again
nResult = ListCurrentString(listConnections, szConnection);
elseif (nResult = SQL_ERROR_VERSION_INADEQUATE) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_INADEQUATE_VERSION ), szServer, szDatabaseServer, szError);
MessageBox( szMessage, MB_OK );
//Show same login dialog again
nResult = ListCurrentString(listConnections, szConnection);
elseif (nResult = SQL_ERROR_MSDE_DISALLOWED) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_MSDE_DISALLOWED ), szServer);
MessageBox( szMessage, MB_OK );
//Show same login dialog again
nResult = ListCurrentString(listConnections, szConnection);
elseif (nResult = SQL_ERROR_ODBC_DRIVER_NOT_FOUND) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_ODBC_DRIVER_NOT_FOUND ), szDatabaseServer, szDatabaseServer);
MessageBox( szMessage, MB_OK );
//Show same login dialog again
nResult = ListCurrentString(listConnections, szConnection);
elseif (nResult = SQL_ERROR_NO_VALID_METADATA) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_NO_VALID_METADATA ), szConnection);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_FAILED_CREATE_DATABASE) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_FAILED_CREATE_DATABASE ), szDB, szDatabaseServer, szServer, szError);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_FAILED_CONNECT_DATABASE) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_FAILED_CONNECT_DATABASE ), szDB, szDatabaseServer, szServer, szError);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_GET_SCHEMA_VERSION) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_GET_SCHEMA_VERSION ), szDatabaseServer, szServer, szDB, szError);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_SET_SCHEMA_VERSION) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_SET_SCHEMA_VERSION ), szDatabaseServer, szServer, szDB, szError);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_SCRIPT_UNABLE_OPEN_FILE) then
SQLRTGetComponentScriptError2("", szError, nErrorCode, nErrorLine, szScriptName, szDatabaseServer, szServer, szDB);
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_SCRIPT_UNABLE_OPEN_FILE ), szScriptName);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_SCRIPT_COMMAND_ERROR) then
SQLRTGetComponentScriptError2("", szError, nErrorCode, nErrorLine, szScriptName, szDatabaseServer, szServer, szDB);
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_RUN_FAILED ), szScriptName, nErrorLine, szError);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_SCRIPT_CONNECTION_NOT_OPEN) then
SQLRTGetComponentScriptError2("", szError, nErrorCode, nErrorLine, szScriptName, szDatabaseServer, szServer, szDB);
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_RUN_SCRIPT_NO_CONNECTION ), szScriptName);
MessageBox( szMessage, MB_OK );
abort;
else
//Unknown error
MessageBox( "There was an unexpected error. Setup will not terminate.", MB_OK );
abort;
endif;
else
//SUCCESS
//Log connection info
Sprintf( szKey, SQL_FORMATSTRING_CONNECTION_SERVER, szConnection );
LogWriteCustomString( szKey, szServer );
Sprintf( szKey, SQL_FORMATSTRING_CONNECTION_USER, szConnection );
LogWriteCustomString( szKey, szUser );
Sprintf( szKey, SQL_FORMATSTRING_CONNECTION_AUTH, szConnection );
if( bWinLogin ) then
LogWriteCustomNumber( szKey, SQL_AUTH_WINDOWS );
else
LogWriteCustomNumber( szKey, SQL_AUTH_SQL );
endif;
//Move on to next connection
nCount++;
bNext = TRUE;
nResult = ListGetNextString(listConnections, szConnection);
endif;
else
//BACK
nCount--;
bNext = FALSE;
nResult = ListSetIndex( listConnections, nCount );
ListCurrentString( listConnections, szConnection );
endif;
endwhile;
// Assign connection name
m_sConnection = szConnection;
if( bNext ) then
return NEXT;
else
return BACK;
endif;
end;
//---------------------------------------------------------------------------
// OnFirstUIBefore
//
// First Install UI Sequence - Before Move Data
//
// The OnFirstUIBefore event is called by OnShowUI when the setup is
// running in first install mode. By default this event displays UI allowing
// the end user to specify installation parameters.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnFirstUIBefore()
number nResult, nLevel, nSize, nSetupType;
string szTitle, szMsg, szOpt1, szOpt2, szLicenseFile;
string szName, szCompany, szTargetPath, szDir, szFeatures;
BOOL bLicenseAccepted;
STRING szMsg1, szMsg2;
NUMBER bvOpt1, bvOpt2;
BOOL bTMP;
begin
nSetupType = COMPLETE;
szDir = TARGETDIR;
szName = "";
szCompany = "";
bLicenseAccepted = FALSE;
// Beginning of UI Sequence
Dlg_Start:
nResult = 0;
Dlg_SdWelcome:
szTitle = "";
szMsg = "";
//{{IS_SCRIPT_TAG(Dlg_SdWelcome)
nResult = SdWelcome( szTitle, szMsg );
//}}IS_SCRIPT_TAG(Dlg_SdWelcome)
if (nResult = BACK) goto Dlg_Start;
Dlg_SdRegisterUser:
szMsg = "";
szTitle = "";
//{{IS_SCRIPT_TAG(Dlg_SdRegisterUser)
nResult = SdRegisterUser( szTitle, szMsg, szName, szCompany );
//}}IS_SCRIPT_TAG(Dlg_SdRegisterUser)
if (nResult = BACK) goto Dlg_SdWelcome;
Dlg_SetupType2:
szTitle = "";
szMsg = "";
nResult = CUSTOM;
//{{IS_SCRIPT_TAG(Dlg_SetupType2)
// nResult = SetupType2( szTitle, szMsg, "", nSetupType, 0 );
//}}IS_SCRIPT_TAG(Dlg_SetupType2)
if (nResult = BACK) then
goto Dlg_SdRegisterUser;
else
nSetupType = nResult;
if (nSetupType != CUSTOM) then
szTargetPath = TARGETDIR;
nSize = 0;
FeatureSelectItem(MEDIA, "RemoveOldDatabase", FALSE);
FeatureSelectItem(MEDIA, "SQLDBScripts", FALSE);
FeatureCompareSizeRequired( MEDIA, szTargetPath, nSize );
if (nSize != 0) then
MessageBox( szSdStr_NotEnoughSpace, WARNING );
goto Dlg_SetupType2;
endif;
endif;
endif;
// Check if sql Server 2008 is required
// if( !IsSQLSrv2008ExpressInstalled() ) then
//MessageBox("There is a need to install sql server", MB_OK);
// FeatureSelectItem(MEDIA, "SQLServerInstall", TRUE);
// else
//MessageBox("No need to install sql server", MB_OK);
// FeatureSelectItem(MEDIA, "SQLServerInstall", FALSE);
// endif;
Dlg_SdAskDestPath2:
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType2;
szTitle = "";
szMsg = "";
if (nSetupType = CUSTOM) then
//{{IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
nResult = SdAskDestPath2( szTitle, szMsg, szDir );
//}}IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
TARGETDIR = szDir;
endif;
if (nResult = BACK) goto Dlg_SetupType2;
Dlg_SdFeatureTree:
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdAskDestPath2;
szTitle = "";
szMsg = "";
szFeatures = "";
nLevel = 2;
if (nSetupType = CUSTOM) then
//{{IS_SCRIPT_TAG(Dlg_SdFeatureTree)
// nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, szFeatures, nLevel );
//}}IS_SCRIPT_TAG(Dlg_SdFeatureTree)
if (nResult = BACK) goto Dlg_SdAskDestPath2;
endif;
MsgInstallWinInstaller:
if( !IsWindowsInstaller45() ) then
nResult = AskYesNo(@txt_AskInstallWinInst, YES);
if( nResult = YES ) then
SdShowMsg(@txt_InstallingWinInst, TRUE);
InstallWinInstaller45();
SdShowMsg(@txt_InstallingWinInst, FALSE);
else
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
abort;
endif;
if ( !IsWindowsInstaller45() ) then
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
abort;
endif;
endif;
MsgInstallFramework:
if( !IsNetFramework40() ) then
nResult = AskYesNo(@txt_AskInstallFramework, YES);
if( nResult = YES ) then
SdShowMsg(@txt_InstallingFramework, TRUE);
InstallFramework();
SdShowMsg(@txt_InstallingFramework, FALSE);
else
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
abort;
endif;
if ( !IsNetFramework40() ) then
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
abort;
endif;
endif;
MsgInstallClickaTell:
if( !isClickaTell() ) then
nResult = AskYesNo(@txt_AskInstallClickaTell, YES);
if( nResult = YES ) then
SdShowMsg(@txt_InstallingClickaTell, TRUE);
InstallClickaTell();
SdShowMsg(@txt_InstallingClickaTell, FALSE);
else
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
abort;
endif;
if ( !isClickaTell() ) then
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
abort;
endif;
endif;
//MsgInstallSqlServer:
// if( FeatureIsItemSelected ( MEDIA, "SQLServerInstall" ) ) then
// //MessageBox("Installing SQLServerInstall ", MB_OK);
// SdShowMsg(@txt_InstallingSqlServer, TRUE);
// InstallSqlServer();
// SdShowMsg(@txt_InstallingSqlServer, FALSE);
// endif;
Dlg_SQLServer:
nResult = OnSQLServerInitialize( nResult );
if( nResult = BACK ) goto Dlg_SdFeatureTree;
//Dlg_SQLServer2:
// if (nSetupType = CUSTOM) then
// nResult = SQLServerDlg(nResult);
// endif;
Dlg_ObjDialogs:
nResult = ShowObjWizardPages( nResult );
//if (nResult = BACK && nSetupType = CUSTOM) goto Dlg_SQLServer2;
//if (nResult = BACK && nSetupType != CUSTOM) goto Dlg_SQLServer;
if (nResult = BACK) goto Dlg_SQLServer;
Dlg_SdStartCopy2:
szTitle = "";
szMsg = "";
//{{IS_SCRIPT_TAG(Dlg_SdStartCopy2)
nResult = SdStartCopy2( szTitle, szMsg );
//}}IS_SCRIPT_TAG(Dlg_SdStartCopy2)
if (nResult = BACK) goto Dlg_ObjDialogs;
// Added in 11.0 - Set appropriate StatusEx static text.
SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );
return 0;
end;
//---------------------------------------------------------------------------
// OnFirstUIAfter
//
// First Install UI Sequence - After Move Data
//
// The OnFirstUIAfter event called by OnShowUI after the file transfer
// of the setup when the setup is running in first install mode. By default
// this event displays UI that informs the end user that the setup has been
// completed successfully.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnFirstUIAfter()
STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
NUMBER bvOpt1, bvOpt2;
NUMBER bShowUpdateServiceDlg;
begin
ShowObjWizardPages(NEXT);
szTitle = "";
szMsg1 = "";
szMsg2 = "";
szOpt1 = "";
szOpt2 = "";
bvOpt1 = FALSE;
bvOpt2 = FALSE;
// Set this to true if you have the update service enabled, and if you want to check for updates.
// Note: the ISUS Starter Edition does not support checking for updates programatically. So,
// only set this to true if you have at least the ISUS Professional Edition.
bShowUpdateServiceDlg = FALSE;
//{{IS_SCRIPT_TAG(Dlg_SdDinishEx)
if ( BATCH_INSTALL ) then
SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
else
// If the update service is enabled, show finish dialog that includes
// update check option.
if( bShowUpdateServiceDlg && ( ENABLED_ISERVICES & SERVICE_ISUPDATE ) ) then
if( SdFinishUpdateEx( szTitle, szMsg1, szMsg2, szOpt1, szOpt2, TRUE ) ) then
// Don't check for updates in silent mode.
if( MODE != SILENTMODE ) then
UpdateServiceCheckForUpdates( "", FALSE );
endif;
endif;
else
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
endif;
endif;
//}}IS_SCRIPT_TAG(Dlg_SdDinishEx)
end;
File 2: featureevents.rul//---------------------------------------------------------------------------
// The Installed event is sent after the feature ProgramFiles
// is installed.
//---------------------------------------------------------------------------
prototype LaunchAndLog( STRING, STRING, NUMBER, STRING, STRING, STRING);
prototype InstallLOG(STRING);
export prototype ProgramFiles_Installed();
function ProgramFiles_Installed()
STRING sChangeXML, sTargetXML, szDll;
STRING sAccountName, sAccountPass;
STRING szCommand;
STRING svConnectionString;
NUMBER nResult;
STRING svResult;
begin
//
// Modify XML file
//
sChangeXML = SUPPORTDIR ^ "ChangeXML.exe";
LongPathToQuote(sChangeXML, TRUE);
sTargetXML = TARGETDIR ^ "ApplicationConfiguration.xml";
LongPathToQuote(sTargetXML, TRUE);
// Get connection parameters
SQLRTGetConnectionInfo( m_sConnection, m_sServer, m_sDB, m_sUser, m_sPassword );
m_bAuthentication = SQLRTGetConnectionAuthentication( m_sConnection );
//if( m_bAuthentication ) then
// Sprintf(svConnectionString, "Data Source=%s;Initial Catalog=%s;Persist Security Info=True;Integrated Security=SSPI;", m_sServer, m_sDB);
//else
//Sprintf(svConnectionString, "Data Source=%s;Initial Catalog=%s;Persist Security Info=True;User Id=%s;Password=%s;", m_sServer, m_sDB, m_sUser, m_sPassword);
Sprintf(svConnectionString, "Data Source=%s;Initial Catalog=%s;Persist Security Info=True;User Id=%s;Password=%s;", m_sServer, m_sDB, "xxxxx", "xxxxx");
//endif;
//nResult = LaunchAppAndWait(sChangeXML, " -s " + sTargetXML + " /Configuration/Database/ConnectionStrings/ConnectionString[1] " + "\"" + svConnectionString + "\"", LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN);
//NumToStr(svResult,nResult);
//MessageBox("ChangeXML: " + svResult, MB_OK );
LaunchAndLog(sChangeXML," -s " + sTargetXML + " /Configuration/Database/ConnectionStrings/ConnectionString[1] " + "\"" + svConnectionString + "\"",LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN,"","","");
end;
function LaunchAndLog( szProgram, szCmdLine, nOption, szNoDisp1, szNoDisp2, szNoDisp3)
NUMBER nRes, nLaunchRes1;
STRING szRes, szLaunchRes1, sLog;
BOOL m_PlainTextPasswords;
begin
m_PlainTextPasswords = TRUE;
StrtLaunching:
sLog = szProgram+" "+szCmdLine;
if( !m_PlainTextPasswords ) then
StrReplace(sLog, szNoDisp1, "*1*",0);
StrReplace(sLog, szNoDisp2, "*2*",0);
StrReplace(sLog, szNoDisp3, "*3*",0);
endif;
InstallLOG("before launching:"+ sLog);
nRes = LaunchAppAndWait(szProgram, szCmdLine, nOption );
NumToStr(szRes, nRes);
InstallLOG("External Result: "+szRes);
nLaunchRes1 = LAAW_PARAMETERS.nLaunchResult ;
NumToStr(szLaunchRes1, nLaunchRes1);
InstallLOG("Internal Result: "+szLaunchRes1);
InstallLOG("after launching: "+ sLog);
//if (LAAW_PARAMETERS.nLaunchResult == -1073741502) then // another instance of MSI installer is running
// if (YES == MyAskYesNo(@text_MsiIsRunning, YES)) then
// goto StrtLaunching;
// else
// abort;
// endif;
//endif;
return nRes;
end;
function InstallLOG( szText )
STRING szFile, szTextPath, szTextFile, svTmp, svDate, svTime;
NUMBER nvFileHandle, nvResult;
begin
szTextPath = FOLDER_TEMP;
szTextFile = "!ISFPLogFile.txt";
szFile = szTextPath ^ szTextFile;
GetSystemInfo(DATE, nvResult, svDate);
StrReplace(svDate, "-", "_", 0);
GetSystemInfo(TIME, nvResult, svTime);
StrReplace(svTime, ":", "_", 0);
if (FileGrep(szFile, "-", svTmp, nvResult, RESTART) == FILE_NOT_FOUND) then
CreateFile(nvFileHandle, szTextPath, szTextFile);
CloseFile(nvFileHandle);
FileInsertLine(szFile, svDate+"_"+svTime + "* new log *" , 0, BEFORE);
endif;
OpenFileMode(FILE_MODE_APPEND);
OpenFile(nvFileHandle, szTextPath, szTextFile);
WriteLine(nvFileHandle, svDate+"_"+svTime+ " " + szText);
CloseFile(nvFileHandle);
end;
I am a C# developer and have taken over the development of a project.
The project was bundled up by the previous developer using InstallShield but this my first encounter with it.
I will have to do some serious reading up but at the minute the project is ready to be installed on some client machines for beta testing and I have a showstopper basically which is preventing me from preparing the application for release.
There appears to be code in place in the installscript for what I need to do but I do not know if it is correct or needs tweaking.
Basically the task at hand is to :
1) Allow the user to select an SQL Server instance from the dropdown on the SQL Dialog Window.. this works fine and the connection is tested as successful or not successfull.
2) If successful, I want my 'ApplicationConfiguration.xml' file to have a connection string added for the server they selected in the dropdown ... or... amend a 'base' connection string in the xml file.... whichever is easiest.
I will attach the current code below.. I notice there is a 'ChangeXML.exe' file ... which I dont have in my project... as mentioned above Im completely new to this but hopefully the attached code will speak for itself.
Hopefully this code may also help someone else as I seen some similar issues througout the forum:)
Many Thanks
File 1: Setup.rul
//===========================================================================
//
// File Name: Setup.rul
//
// Description: Blank setup main script file
//
// Comments: Blank setup is an empty setup project. If you want to
// create a new project via. step-by step instructions use the
// Project Assistant.
//
//===========================================================================
// Included header files ----------------------------------------------------
#include "ifx.h";
// variables storing sql server connection string configuration
STRING m_sConnection, m_sServer, m_sDB, m_sUser, m_sPassword;
STRING m_sConnection2, m_sServer2, m_sDB2, m_sUser2, m_sPassword2;
BOOL m_bAuthentication;
BOOL m_bAuthentication2;
#include "featureevents.rul"
#include "auxiliary.rul"
#include "utils.rul"
#include "sql.rul"
//---------------------------------------------------------------------------
// OnSQLServerInitialize
//
// The OnSQLServerInitialize event is called by OnFirstUIBefore to
// establish any connections necessary for SQL Server support.
//
// This function will initialize the SQL Server runtime, and attempt to
// make any necessary SQL Server connections, displaying a login dialog
// for each one.
//
// Parameter nBtn indicates whether NEXT or BACK was the result of the
// previously displayed dialog. It is for information purposes only.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function number OnSQLServerInitialize( nBtn )
number nResult, nErrorCode, nErrorLine;
number nCount;
string szSettingsFile;
string szConnection;
string szServer, szDB, szUser, szPassword;
string szMessage;
string szError[MAX_PATH];
string szKey;
string szDatabaseServer[MAX_PATH];
string szScriptName;
LIST listConnections;
BOOL bWinLogin;
BOOL bNext;
begin
//First initialize SQL Server runtime
szSettingsFile = SUPPORTDIR ^ "SQLRT.ini";
SQLRTInitialize( szSettingsFile );
//Get the names of all the necessary connections
listConnections = SQLRTGetConnections();
ListGetFirstString (listConnections, szConnection);
nCount = 0;
//determine if NEXT or BACK will be returned
//if there are no connections to make
if( nBtn != BACK ) then
bNext = TRUE;
else
bNext = FALSE;
//start at end if going BACK
while (ISERR_SUCCESS = ListGetNextString( listConnections, szConnection ) );
nCount++;
endwhile;
endif;
// Login for each connection
while (nResult = ISERR_SUCCESS)
//Get Default values for connection
SQLRTGetConnectionInfo( szConnection, szServer, szDB, szUser, szPassword );
bWinLogin = SQLRTGetConnectionAuthentication( szConnection );
// Display login dialog (without connection name)
// COMMENT OUT TO SWAP DIALOGS
nResult = SQLServerSelectLogin( szServer, szUser, szPassword, bWinLogin );
// Display login dialog (with connection name)
// UNCOMMENT TO SWAP DIALOGS
// nResult = SQLServerSelectLoginEx( szConnection, szServer, szUser, szPassword, bWinLogin );
if( nResult = NEXT ) then
//store data in case we need it again
SQLRTPutConnectionInfo( szConnection, szServer, szUser, szPassword );
//try connection
nResult = SQLRTConnect2( szConnection, szServer, bWinLogin, szUser, szPassword, szDatabaseServer );
if( nResult < ISERR_SUCCESS ) then
SQLRTGetLastError( szError );
if (nResult = SQL_ERROR_LOGIN_FAILED) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_LOGIN_FAILED ), szDatabaseServer, szError);
MessageBox( szMessage, MB_OK );
//Show same login dialog again
nResult = ListCurrentString(listConnections, szConnection);
elseif (nResult = SQL_ERROR_VERSION_MISSING) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_VERSION_MISSING ), szDatabaseServer);
MessageBox( szMessage, MB_OK );
//Show same login dialog again
nResult = ListCurrentString(listConnections, szConnection);
elseif (nResult = SQL_ERROR_VERSION_INADEQUATE) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_INADEQUATE_VERSION ), szServer, szDatabaseServer, szError);
MessageBox( szMessage, MB_OK );
//Show same login dialog again
nResult = ListCurrentString(listConnections, szConnection);
elseif (nResult = SQL_ERROR_MSDE_DISALLOWED) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_MSDE_DISALLOWED ), szServer);
MessageBox( szMessage, MB_OK );
//Show same login dialog again
nResult = ListCurrentString(listConnections, szConnection);
elseif (nResult = SQL_ERROR_ODBC_DRIVER_NOT_FOUND) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_ODBC_DRIVER_NOT_FOUND ), szDatabaseServer, szDatabaseServer);
MessageBox( szMessage, MB_OK );
//Show same login dialog again
nResult = ListCurrentString(listConnections, szConnection);
elseif (nResult = SQL_ERROR_NO_VALID_METADATA) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_NO_VALID_METADATA ), szConnection);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_FAILED_CREATE_DATABASE) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_FAILED_CREATE_DATABASE ), szDB, szDatabaseServer, szServer, szError);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_FAILED_CONNECT_DATABASE) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_FAILED_CONNECT_DATABASE ), szDB, szDatabaseServer, szServer, szError);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_GET_SCHEMA_VERSION) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_GET_SCHEMA_VERSION ), szDatabaseServer, szServer, szDB, szError);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_SET_SCHEMA_VERSION) then
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_SET_SCHEMA_VERSION ), szDatabaseServer, szServer, szDB, szError);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_SCRIPT_UNABLE_OPEN_FILE) then
SQLRTGetComponentScriptError2("", szError, nErrorCode, nErrorLine, szScriptName, szDatabaseServer, szServer, szDB);
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_SCRIPT_UNABLE_OPEN_FILE ), szScriptName);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_SCRIPT_COMMAND_ERROR) then
SQLRTGetComponentScriptError2("", szError, nErrorCode, nErrorLine, szScriptName, szDatabaseServer, szServer, szDB);
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_RUN_FAILED ), szScriptName, nErrorLine, szError);
MessageBox( szMessage, MB_OK );
abort;
elseif (nResult = SQL_ERROR_SCRIPT_CONNECTION_NOT_OPEN) then
SQLRTGetComponentScriptError2("", szError, nErrorCode, nErrorLine, szScriptName, szDatabaseServer, szServer, szDB);
Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_RUN_SCRIPT_NO_CONNECTION ), szScriptName);
MessageBox( szMessage, MB_OK );
abort;
else
//Unknown error
MessageBox( "There was an unexpected error. Setup will not terminate.", MB_OK );
abort;
endif;
else
//SUCCESS
//Log connection info
Sprintf( szKey, SQL_FORMATSTRING_CONNECTION_SERVER, szConnection );
LogWriteCustomString( szKey, szServer );
Sprintf( szKey, SQL_FORMATSTRING_CONNECTION_USER, szConnection );
LogWriteCustomString( szKey, szUser );
Sprintf( szKey, SQL_FORMATSTRING_CONNECTION_AUTH, szConnection );
if( bWinLogin ) then
LogWriteCustomNumber( szKey, SQL_AUTH_WINDOWS );
else
LogWriteCustomNumber( szKey, SQL_AUTH_SQL );
endif;
//Move on to next connection
nCount++;
bNext = TRUE;
nResult = ListGetNextString(listConnections, szConnection);
endif;
else
//BACK
nCount--;
bNext = FALSE;
nResult = ListSetIndex( listConnections, nCount );
ListCurrentString( listConnections, szConnection );
endif;
endwhile;
// Assign connection name
m_sConnection = szConnection;
if( bNext ) then
return NEXT;
else
return BACK;
endif;
end;
//---------------------------------------------------------------------------
// OnFirstUIBefore
//
// First Install UI Sequence - Before Move Data
//
// The OnFirstUIBefore event is called by OnShowUI when the setup is
// running in first install mode. By default this event displays UI allowing
// the end user to specify installation parameters.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnFirstUIBefore()
number nResult, nLevel, nSize, nSetupType;
string szTitle, szMsg, szOpt1, szOpt2, szLicenseFile;
string szName, szCompany, szTargetPath, szDir, szFeatures;
BOOL bLicenseAccepted;
STRING szMsg1, szMsg2;
NUMBER bvOpt1, bvOpt2;
BOOL bTMP;
begin
nSetupType = COMPLETE;
szDir = TARGETDIR;
szName = "";
szCompany = "";
bLicenseAccepted = FALSE;
// Beginning of UI Sequence
Dlg_Start:
nResult = 0;
Dlg_SdWelcome:
szTitle = "";
szMsg = "";
//{{IS_SCRIPT_TAG(Dlg_SdWelcome)
nResult = SdWelcome( szTitle, szMsg );
//}}IS_SCRIPT_TAG(Dlg_SdWelcome)
if (nResult = BACK) goto Dlg_Start;
Dlg_SdRegisterUser:
szMsg = "";
szTitle = "";
//{{IS_SCRIPT_TAG(Dlg_SdRegisterUser)
nResult = SdRegisterUser( szTitle, szMsg, szName, szCompany );
//}}IS_SCRIPT_TAG(Dlg_SdRegisterUser)
if (nResult = BACK) goto Dlg_SdWelcome;
Dlg_SetupType2:
szTitle = "";
szMsg = "";
nResult = CUSTOM;
//{{IS_SCRIPT_TAG(Dlg_SetupType2)
// nResult = SetupType2( szTitle, szMsg, "", nSetupType, 0 );
//}}IS_SCRIPT_TAG(Dlg_SetupType2)
if (nResult = BACK) then
goto Dlg_SdRegisterUser;
else
nSetupType = nResult;
if (nSetupType != CUSTOM) then
szTargetPath = TARGETDIR;
nSize = 0;
FeatureSelectItem(MEDIA, "RemoveOldDatabase", FALSE);
FeatureSelectItem(MEDIA, "SQLDBScripts", FALSE);
FeatureCompareSizeRequired( MEDIA, szTargetPath, nSize );
if (nSize != 0) then
MessageBox( szSdStr_NotEnoughSpace, WARNING );
goto Dlg_SetupType2;
endif;
endif;
endif;
// Check if sql Server 2008 is required
// if( !IsSQLSrv2008ExpressInstalled() ) then
//MessageBox("There is a need to install sql server", MB_OK);
// FeatureSelectItem(MEDIA, "SQLServerInstall", TRUE);
// else
//MessageBox("No need to install sql server", MB_OK);
// FeatureSelectItem(MEDIA, "SQLServerInstall", FALSE);
// endif;
Dlg_SdAskDestPath2:
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType2;
szTitle = "";
szMsg = "";
if (nSetupType = CUSTOM) then
//{{IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
nResult = SdAskDestPath2( szTitle, szMsg, szDir );
//}}IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
TARGETDIR = szDir;
endif;
if (nResult = BACK) goto Dlg_SetupType2;
Dlg_SdFeatureTree:
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdAskDestPath2;
szTitle = "";
szMsg = "";
szFeatures = "";
nLevel = 2;
if (nSetupType = CUSTOM) then
//{{IS_SCRIPT_TAG(Dlg_SdFeatureTree)
// nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, szFeatures, nLevel );
//}}IS_SCRIPT_TAG(Dlg_SdFeatureTree)
if (nResult = BACK) goto Dlg_SdAskDestPath2;
endif;
MsgInstallWinInstaller:
if( !IsWindowsInstaller45() ) then
nResult = AskYesNo(@txt_AskInstallWinInst, YES);
if( nResult = YES ) then
SdShowMsg(@txt_InstallingWinInst, TRUE);
InstallWinInstaller45();
SdShowMsg(@txt_InstallingWinInst, FALSE);
else
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
abort;
endif;
if ( !IsWindowsInstaller45() ) then
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
abort;
endif;
endif;
MsgInstallFramework:
if( !IsNetFramework40() ) then
nResult = AskYesNo(@txt_AskInstallFramework, YES);
if( nResult = YES ) then
SdShowMsg(@txt_InstallingFramework, TRUE);
InstallFramework();
SdShowMsg(@txt_InstallingFramework, FALSE);
else
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
abort;
endif;
if ( !IsNetFramework40() ) then
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
abort;
endif;
endif;
MsgInstallClickaTell:
if( !isClickaTell() ) then
nResult = AskYesNo(@txt_AskInstallClickaTell, YES);
if( nResult = YES ) then
SdShowMsg(@txt_InstallingClickaTell, TRUE);
InstallClickaTell();
SdShowMsg(@txt_InstallingClickaTell, FALSE);
else
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
abort;
endif;
if ( !isClickaTell() ) then
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
abort;
endif;
endif;
//MsgInstallSqlServer:
// if( FeatureIsItemSelected ( MEDIA, "SQLServerInstall" ) ) then
// //MessageBox("Installing SQLServerInstall ", MB_OK);
// SdShowMsg(@txt_InstallingSqlServer, TRUE);
// InstallSqlServer();
// SdShowMsg(@txt_InstallingSqlServer, FALSE);
// endif;
Dlg_SQLServer:
nResult = OnSQLServerInitialize( nResult );
if( nResult = BACK ) goto Dlg_SdFeatureTree;
//Dlg_SQLServer2:
// if (nSetupType = CUSTOM) then
// nResult = SQLServerDlg(nResult);
// endif;
Dlg_ObjDialogs:
nResult = ShowObjWizardPages( nResult );
//if (nResult = BACK && nSetupType = CUSTOM) goto Dlg_SQLServer2;
//if (nResult = BACK && nSetupType != CUSTOM) goto Dlg_SQLServer;
if (nResult = BACK) goto Dlg_SQLServer;
Dlg_SdStartCopy2:
szTitle = "";
szMsg = "";
//{{IS_SCRIPT_TAG(Dlg_SdStartCopy2)
nResult = SdStartCopy2( szTitle, szMsg );
//}}IS_SCRIPT_TAG(Dlg_SdStartCopy2)
if (nResult = BACK) goto Dlg_ObjDialogs;
// Added in 11.0 - Set appropriate StatusEx static text.
SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );
return 0;
end;
//---------------------------------------------------------------------------
// OnFirstUIAfter
//
// First Install UI Sequence - After Move Data
//
// The OnFirstUIAfter event called by OnShowUI after the file transfer
// of the setup when the setup is running in first install mode. By default
// this event displays UI that informs the end user that the setup has been
// completed successfully.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnFirstUIAfter()
STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
NUMBER bvOpt1, bvOpt2;
NUMBER bShowUpdateServiceDlg;
begin
ShowObjWizardPages(NEXT);
szTitle = "";
szMsg1 = "";
szMsg2 = "";
szOpt1 = "";
szOpt2 = "";
bvOpt1 = FALSE;
bvOpt2 = FALSE;
// Set this to true if you have the update service enabled, and if you want to check for updates.
// Note: the ISUS Starter Edition does not support checking for updates programatically. So,
// only set this to true if you have at least the ISUS Professional Edition.
bShowUpdateServiceDlg = FALSE;
//{{IS_SCRIPT_TAG(Dlg_SdDinishEx)
if ( BATCH_INSTALL ) then
SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
else
// If the update service is enabled, show finish dialog that includes
// update check option.
if( bShowUpdateServiceDlg && ( ENABLED_ISERVICES & SERVICE_ISUPDATE ) ) then
if( SdFinishUpdateEx( szTitle, szMsg1, szMsg2, szOpt1, szOpt2, TRUE ) ) then
// Don't check for updates in silent mode.
if( MODE != SILENTMODE ) then
UpdateServiceCheckForUpdates( "", FALSE );
endif;
endif;
else
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
endif;
endif;
//}}IS_SCRIPT_TAG(Dlg_SdDinishEx)
end;
File 2: featureevents.rul//---------------------------------------------------------------------------
// The Installed event is sent after the feature ProgramFiles
// is installed.
//---------------------------------------------------------------------------
prototype LaunchAndLog( STRING, STRING, NUMBER, STRING, STRING, STRING);
prototype InstallLOG(STRING);
export prototype ProgramFiles_Installed();
function ProgramFiles_Installed()
STRING sChangeXML, sTargetXML, szDll;
STRING sAccountName, sAccountPass;
STRING szCommand;
STRING svConnectionString;
NUMBER nResult;
STRING svResult;
begin
//
// Modify XML file
//
sChangeXML = SUPPORTDIR ^ "ChangeXML.exe";
LongPathToQuote(sChangeXML, TRUE);
sTargetXML = TARGETDIR ^ "ApplicationConfiguration.xml";
LongPathToQuote(sTargetXML, TRUE);
// Get connection parameters
SQLRTGetConnectionInfo( m_sConnection, m_sServer, m_sDB, m_sUser, m_sPassword );
m_bAuthentication = SQLRTGetConnectionAuthentication( m_sConnection );
//if( m_bAuthentication ) then
// Sprintf(svConnectionString, "Data Source=%s;Initial Catalog=%s;Persist Security Info=True;Integrated Security=SSPI;", m_sServer, m_sDB);
//else
//Sprintf(svConnectionString, "Data Source=%s;Initial Catalog=%s;Persist Security Info=True;User Id=%s;Password=%s;", m_sServer, m_sDB, m_sUser, m_sPassword);
Sprintf(svConnectionString, "Data Source=%s;Initial Catalog=%s;Persist Security Info=True;User Id=%s;Password=%s;", m_sServer, m_sDB, "xxxxx", "xxxxx");
//endif;
//nResult = LaunchAppAndWait(sChangeXML, " -s " + sTargetXML + " /Configuration/Database/ConnectionStrings/ConnectionString[1] " + "\"" + svConnectionString + "\"", LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN);
//NumToStr(svResult,nResult);
//MessageBox("ChangeXML: " + svResult, MB_OK );
LaunchAndLog(sChangeXML," -s " + sTargetXML + " /Configuration/Database/ConnectionStrings/ConnectionString[1] " + "\"" + svConnectionString + "\"",LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN,"","","");
end;
function LaunchAndLog( szProgram, szCmdLine, nOption, szNoDisp1, szNoDisp2, szNoDisp3)
NUMBER nRes, nLaunchRes1;
STRING szRes, szLaunchRes1, sLog;
BOOL m_PlainTextPasswords;
begin
m_PlainTextPasswords = TRUE;
StrtLaunching:
sLog = szProgram+" "+szCmdLine;
if( !m_PlainTextPasswords ) then
StrReplace(sLog, szNoDisp1, "*1*",0);
StrReplace(sLog, szNoDisp2, "*2*",0);
StrReplace(sLog, szNoDisp3, "*3*",0);
endif;
InstallLOG("before launching:"+ sLog);
nRes = LaunchAppAndWait(szProgram, szCmdLine, nOption );
NumToStr(szRes, nRes);
InstallLOG("External Result: "+szRes);
nLaunchRes1 = LAAW_PARAMETERS.nLaunchResult ;
NumToStr(szLaunchRes1, nLaunchRes1);
InstallLOG("Internal Result: "+szLaunchRes1);
InstallLOG("after launching: "+ sLog);
//if (LAAW_PARAMETERS.nLaunchResult == -1073741502) then // another instance of MSI installer is running
// if (YES == MyAskYesNo(@text_MsiIsRunning, YES)) then
// goto StrtLaunching;
// else
// abort;
// endif;
//endif;
return nRes;
end;
function InstallLOG( szText )
STRING szFile, szTextPath, szTextFile, svTmp, svDate, svTime;
NUMBER nvFileHandle, nvResult;
begin
szTextPath = FOLDER_TEMP;
szTextFile = "!ISFPLogFile.txt";
szFile = szTextPath ^ szTextFile;
GetSystemInfo(DATE, nvResult, svDate);
StrReplace(svDate, "-", "_", 0);
GetSystemInfo(TIME, nvResult, svTime);
StrReplace(svTime, ":", "_", 0);
if (FileGrep(szFile, "-", svTmp, nvResult, RESTART) == FILE_NOT_FOUND) then
CreateFile(nvFileHandle, szTextPath, szTextFile);
CloseFile(nvFileHandle);
FileInsertLine(szFile, svDate+"_"+svTime + "* new log *" , 0, BEFORE);
endif;
OpenFileMode(FILE_MODE_APPEND);
OpenFile(nvFileHandle, szTextPath, szTextFile);
WriteLine(nvFileHandle, svDate+"_"+svTime+ " " + szText);
CloseFile(nvFileHandle);
end;
(3) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 12, 2011
07:52 AM
Hi all ... I tried loads of stuff including those suggested by these 2 links:
http://community.flexerasoftware.com/showthread.php?p=449596
http://kb.flexerasoftware.com/doc/Helpnet/installshield14helplib/XML-MSIProps.htm
...but still no luck... can anyone alter my setup.rul code in the post to show how to alter the XML file?
thanks
http://community.flexerasoftware.com/showthread.php?p=449596
http://kb.flexerasoftware.com/doc/Helpnet/installshield14helplib/XML-MSIProps.htm
...but still no luck... can anyone alter my setup.rul code in the post to show how to alter the XML file?
thanks
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 12, 2011
12:22 PM
If I have the changes in my installscript, does the xml file need updated?
I need to update the remote SQL connections string in my sample xml file below:
-
-
-
Data Source="USER_SERVER";Initial Catalog=XXXXX;User ID=[USER_ID];Password="USER_PASSWORD"
Data Source=127.0.0.1;Initial Catalog=XXXXX;User ID=xxxxxxx;Password=xxxxxxx
Data Source=127.0.0.1;Initial Catalog=XXXXX;User ID=xxxxxxx;Password=xxxxxxx
Also attached below is the OnSQLServerInitialize function where im using the TextSubSetValue method
function number OnSQLServerInitialize( nBtn )
number nResult, nErrorCode, nErrorLine;
number nCount;
string szSettingsFile;
string szConnection;
string szServer, szDB, szUser, szPassword;
string szMessage;
string szError[MAX_PATH];
string szKey;
string szDatabaseServer[MAX_PATH];
string szScriptName;
LIST listConnections;
BOOL bWinLogin;
BOOL bNext;
begin
//First initialize SQL Server runtime
szSettingsFile = SUPPORTDIR ^ "SQLRT.ini";
SQLRTInitialize( szSettingsFile );
//Get the names of all the necessary connections
listConnections = SQLRTGetConnections();
ListGetFirstString (listConnections, szConnection);
nCount = 0;
//determine if NEXT or BACK will be returned
//if there are no connections to make
if( nBtn != BACK ) then
bNext = TRUE;
else
bNext = FALSE;
//start at end if going BACK
while (ISERR_SUCCESS = ListGetNextString( listConnections, szConnection ) );
nCount++;
endwhile;
endif;
// Login for each connection
while (nResult = ISERR_SUCCESS)
//Get Default values for connection
SQLRTGetConnectionInfo( szConnection, szServer, szDB, szUser, szPassword );
bWinLogin = SQLRTGetConnectionAuthentication( szConnection );
// Display login dialog (without connection name)
// COMMENT OUT TO SWAP DIALOGS
nResult = SQLServerSelectLogin( szServer, szUser, szPassword, bWinLogin );
TextSubSetValue("",szServer , TRUE);
I need to update the remote SQL connections string in my sample xml file below:
-
-
-
Also attached below is the OnSQLServerInitialize function where im using the TextSubSetValue method
function number OnSQLServerInitialize( nBtn )
number nResult, nErrorCode, nErrorLine;
number nCount;
string szSettingsFile;
string szConnection;
string szServer, szDB, szUser, szPassword;
string szMessage;
string szError[MAX_PATH];
string szKey;
string szDatabaseServer[MAX_PATH];
string szScriptName;
LIST listConnections;
BOOL bWinLogin;
BOOL bNext;
begin
//First initialize SQL Server runtime
szSettingsFile = SUPPORTDIR ^ "SQLRT.ini";
SQLRTInitialize( szSettingsFile );
//Get the names of all the necessary connections
listConnections = SQLRTGetConnections();
ListGetFirstString (listConnections, szConnection);
nCount = 0;
//determine if NEXT or BACK will be returned
//if there are no connections to make
if( nBtn != BACK ) then
bNext = TRUE;
else
bNext = FALSE;
//start at end if going BACK
while (ISERR_SUCCESS = ListGetNextString( listConnections, szConnection ) );
nCount++;
endwhile;
endif;
// Login for each connection
while (nResult = ISERR_SUCCESS)
//Get Default values for connection
SQLRTGetConnectionInfo( szConnection, szServer, szDB, szUser, szPassword );
bWinLogin = SQLRTGetConnectionAuthentication( szConnection );
// Display login dialog (without connection name)
// COMMENT OUT TO SWAP DIALOGS
nResult = SQLServerSelectLogin( szServer, szUser, szPassword, bWinLogin );
TextSubSetValue("
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 26, 2011
11:40 AM
Please take a look at my other post that I made in regards to how to update xml config file.
I believe what you are trying to achieve is pretty simple. All you need to do is call the method to update xml once you have all parameters, perhaps at the end of OnSQLLogin().
Let me know if you have any questions.
I believe what you are trying to achieve is pretty simple. All you need to do is call the method to update xml once you have all parameters, perhaps at the end of OnSQLLogin().
Let me know if you have any questions.
![](/skins/images/3B39CE851FDD5528C393F146EB70A2D0/responsive_peak/images/icon_anonymous_message.png)