cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vve_77
Level 3

SQLRTComponentInstall returns SQL_ERROR_ABORT, how to investigate ?

Hello all,

We're evaluating IS 2008, mainly for the SQL support. The problem is that the call to SQLRTComponentInstall just returns SQL_ERROR_ABORT. We want to create a catalog (when it's not already there) using a SQL script.

- SQL Server Express 2005
- It's an InstallScript application
- The SQL script belongs to a feature, and there's a corresponding component
- OnSQLComponentInstalled gets called for the component

I've changed the default OnSQLServerInitialize so that it continues when the following requirements are met: a) you can log on to the database using the credentials of the SQL connection and b) the catalog isn't already there.

OnSQLServerInitialize works fine, and the script itself runs correctly when you run it in the query analyser.

I must be missing something obvious. Any thoughts on this ?

Thanks in advance.
Labels (1)
0 Kudos
(8) Replies
vve_77
Level 3

I've found something: it appears that when you want to create new databases in a SQL script, the catalog in "SQL Scripts" has to be empty. Otherwise, the script doesn't run at all.
0 Kudos
Diofantos
Level 3

Hello

I have been stumbled by this behaviour for a few days now. I used previuos version of InstallShield earlier with same script and it always installed when creating patches. But now with IS 2008 it doesnt work.

I might be just plain stupid, or I am only tired. Can you please describe your solution to empty the "SQL Scripts" folder before calling the functions please?

// Per
0 Kudos
ISNewone
Level 3

Are you sure inside OnSQLServerInitialize, that the SQL server could be logged in ?

Also, make sure you turn on the "SQL Server And Windows Authentication mode" option.

If all failed, try look at the log file for error.
0 Kudos
TheTraveler
Level 8

Hello Everyone,

There was a time that Install Shield didn't have SQL support. I created my own set of functions that can run SQL script files by creating ADO COM objects. Here is what I'm capable of doing with the functions I created.

1) I'm able to execute Create database, in any location on the SQL Server System as long as SQL server is allowed to create the database files in that location.

2) Execute SQL code and if it errors, I not only now the location in the file upon where it errors, I know what SQL code contains the problem and I get the error message from SQL server. I also give the user the option to continue.

3) When it executes a SQL file, I get a nice Status Bar to tell me how far along it is in the file.

There is a lot more too, but this gives an idea of what you can do... The beauty of it all is, all of this can be done in Install Shield Script code.

If you are interested, I can help you get started with what I know...
0 Kudos
TheTraveler
Level 8

Here is a small sample on how this can be done...
0 Kudos
Diofantos
Level 3

Hi and thanx for the quick replies..

This will probably be a long post, but hopefully answer all of your questions... Which hopefully will help me in the end.

I have version 6 and 7 of this software released on DVD with 5-10 patches provided via internet (done with IS 12). Version 8 went away for a few weeks ago and now I am working on first patch but this one isnt updating the databases (using IS 2008 for Vista support).

in version 6 and 7 we had MSDE 2000 as db provider, now we have SQL server 2005 express since we need to support installation on Vista.

in version 6 and 7 the installation log file for our application looks like this (some copy and paste from it)
Version 7 DVD log...

Start Installation on clean computer.
~~~~~~
installed prerequirements (i.e. .Net 2.0, Java 1.4.2 SDK + RE)
~~~~~~
11:20:30 ---MSDE2000_Installed()
11:21:44 MSDE Setup successfully launched...

11:21:46 ---OnSQLServerInitialize( 1 )
11:21:52 Connecting on connection Core, server (LOCAL)\APP, as user sa
11:21:52 Connection successful
11:21:56 Connecting on connection ServiceManager, server (LOCAL)\APP, as user sa
11:21:56 Connection successful
11:22:00 Connecting on connection Vehicle, server (LOCAL)\APP, as user sa
11:22:00 Connection successful
11:22:03 Connecting on connection UserStore, server (LOCAL)\APP, as user sa
11:22:03 Connection successful
11:22:06 Connecting on connection master, server (LOCAL)\APP, as user sa
11:22:06 Connection successful
11:22:09 Connecting on connection Feedback, server (LOCAL)\APP, as user sa
11:22:09 Connection successful
11:22:09 Done processing DB connections
~~~~~~
Create Vehicle tables and fill with information... (looks same for Core, ServiceManager, UserStore and Feedback)

11:29:38 ---OnSQLComponentInstalled(SQL_(1)_Vehicle_DropDb)

11:29:38 ---OnIISComponentInstalled(SQL_(1)_Vehicle_DropDb)

11:29:39 ---OnSQLComponentInstalled(SQL_(2)_Vehicle_CreateDb)

11:29:43 ---OnIISComponentInstalled(SQL_(2)_Vehicle_CreateDb)

11:29:43 ---OnSQLComponentInstalled(SQL_(3)_Vehicle_InitLoad)

11:29:44 ---OnIISComponentInstalled(SQL_(3)_Vehicle_InitLoad)


Version 7 patch log...

Start Update on Version 7 computer.
20:24:26 ---MSDE2000_Installed()
20:24:26 ***DIFFERENTIAL MEDIA***

20:24:27 ---OnSQLServerInitialize( 1 )
20:24:35 Connecting on connection Core, server (LOCAL)\APP, as user sa
20:24:35 Connection successful
20:24:38 Connecting on connection ServiceManager, server (LOCAL)\APP, as user sa
20:24:38 Connection successful
20:24:41 Connecting on connection Vehicle, server (LOCAL)\APP, as user sa
20:24:41 Connection successful
20:24:44 Connecting on connection UserStore, server (LOCAL)\APP, as user sa
20:24:44 Connection successful
20:24:46 Connecting on connection master, server (LOCAL)\APP, as user sa
20:24:47 Connection successful
20:24:49 Connecting on connection Feedback, server (LOCAL)\APP, as user sa
20:24:50 Connection successful
20:24:50 Done processing DB connections
~~~~~~
Vehicle database exists, so clear it and fill with new values... new CreateDB and new InitLoad is in package...

20:25:09 ---OnSQLComponentInstalled(SQL_(1)_Vehicle_DropDb)

20:25:09 ---OnIISComponentInstalled(SQL_(1)_Vehicle_DropDb)

20:25:10 ---OnSQLComponentInstalled(SQL_(2)_Vehicle_CreateDb)

20:25:15 ---OnIISComponentInstalled(SQL_(2)_Vehicle_CreateDb)

20:25:15 ---OnSQLComponentInstalled(SQL_(3)_Vehicle_InitLoad)

20:25:17 ---OnIISComponentInstalled(SQL_(3)_Vehicle_InitLoad)




and this is the functions (OnSQLServerInitialize())
[CODE]
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;

STRING szTmp;

begin

_Log(" ");
Sprintf(szTmp, "---OnSQLServerInitialize( %i )", nBtn);
_Log(szTmp);

UpdateProgressBar("Initializing local database connections...", 1);

//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 );

// The above command SQLRTGetConnectionAuthentication( szConnection );
// does not seem to work
// So we set all SQL Server Authentications to Win
bWinLogin = TRUE;

// Display login dialog (without connection name)
// COMMENT OUT TO SWAP DIALOGS
// We do not want to use any dialogue /Georg
//nResult = SQLServerSelectLogin( szServer, szUser, szPassword, bWinLogin );
nResult = NEXT;

// 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 );

Sprintf(szTmp, " Connecting on connection %s, server %s, as user %s", szConnection, szServer, szUser);
_Log(szTmp);

if( nResult < ISERR_SUCCESS ) then

Sprintf(szTmp, " !ERROR connecting result: %i", nResult);
_Log(szTmp);

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
Sprintf(szTmp, " Connection successful");
_Log(szTmp);

//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;

_Log(" Done processing DB connections");

if( bNext ) then
return NEXT;
else
return BACK;
endif;

end;
[/CODE]

and (OnSQLComponentInstalled())

//---------------------------------------------------------------------------
// OnSQLComponentInstalled
//
// The SQLComponentInstalled event is called after each component is
// installed so any SQL scripts attached to that component can be run.
//
// szComponent will have the name of the component that has been installed.
//---------------------------------------------------------------------------
function OnSQLComponentInstalled(szComponent)
string szMessage, szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
string szError;
string szScriptName, szProductName, szServer, szDB;
number nErrorType, nLine;
number nResult;
BOOL bvOpt1, bvOpt2;

STRING szLine;

STRING szResult;

begin

_Log(" ");
_Log("---OnSQLComponentInstalled(" + szComponent + ")");

#ifndef _UPDATE

if( SQLRTGetBatchMode() ) then

ISSQLServerAddToBatchInstall( szComponent );

else

// Run scripts now

nResult = SQLRTComponentInstall( szComponent );

// 2 lines used for debugging SQL scripts not launching with TT 1.08.10 update 2008-04-29 - Per
NumToStr(szResult, nResult);
MessageBox("SQLRTComponentInstall result = '" + szResult + "'", INFORMATION);

if( nResult = SQL_ERROR_ABORT ) then

// Get error message
SQLRTGetComponentScriptError2( szComponent, szError, nErrorType, nLine, szScriptName, szProductName, szServer, szDB );

NumToStr(szLine, nLine);
_Log("SQL ERROR: " + szError + ", " + szServer + ", " + szDB + ", " + szScriptName + ", " + szLine);

if( nErrorType = SQL_ERROR_SCRIPT_UNABLE_OPEN_FILE ) then

Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_SCRIPT_UNABLE_OPEN_FILE ), szScriptName);

elseif( nErrorType = SQL_ERROR_SCRIPT_COMMAND_ERROR ) then

Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_RUN_FAILED ), szScriptName, nLine, szError);

elseif( nErrorType = SQL_ERROR_SCRIPT_CONNECTION_NOT_OPEN ) then

Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_RUN_SCRIPT_NO_CONNECTION ), szScriptName);

elseif (nErrorType = SQL_ERROR_GET_SCHEMA_VERSION) then

Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_GET_SCHEMA_VERSION ), szProductName, szServer, szDB, szError);

elseif (nErrorType = SQL_ERROR_SET_SCHEMA_VERSION) then

Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_SET_SCHEMA_VERSION ), szProductName, szServer, szDB, szError);

else

Sprintf(szMessage, SdLoadString( IDS_IFX_SQL_ERROR_RUN_SCRIPT_UNEXPECTED ));

endif;

// Display error
MessageBox( " !" + szMessage + "\n(Additional info: " + szError + ")", SEVERE );

_Log("szComponent:" + szComponent);
_Log("szScriptName:" + szScriptName);
_Log("szProductName:" + szProductName);
_Log("szServer:" + szServer);
_Log("szDB:" + szDB);

// Close the current dialog.
EndCurrentDialog();

// Rollback SQL Scripts
SQLRTDoRollbackAll();

//Display Finish dialog.
szTitle = "";
szMsg1 = SdLoadString( SD_STR_ONCANCELING_FINISH_MSG1 );
szMsg2 = SdLoadString( SD_STR_ONCANCELING_FINISH_MSG2 );
szOpt1 = "";
szOpt2 = "";
bvOpt1 = FALSE;
bvOpt2 = FALSE;
SdFinish ( szTitle, szMsg1, szMsg2 , szOpt1, szOpt2, bvOpt1, bvOpt2 );

abort;
endif;
endif;
#endif
end;


and the not so important (in this case)

//---------------------------------------------------------------------------
// OnIISComponentInstalled
//
// The IISComponentInstalled event is called after each component is
// installed so any iis info attached to that component can be installed.
//
// szComponent will have the name of the component that has been installed.
//---------------------------------------------------------------------------
function int OnIISComponentInstalled(szComponent)
begin

_Log(" ");
_Log("---OnIISComponentInstalled(" + szComponent + ")");
return IISRTComponentInstall( szComponent );

end;




This is how it looks in Version 8
Version 8 DVD log...

Start Installation on clean computer.
~~~~~~
installed prerequirements (i.e. .Net 3.0, Java 1.4.2 SDK + RE)
~~~~~~
12:28:24 ---FEATURE_SQLExpress_Installed()
12:28:55 SQLExpress Setup successfully launched...

12:28:50 ---OnSQLServerInitialize( 1 )
12:28:52 Connecting on connection Core, server (LOCAL)\APP, as user sa
12:28:52 Connection successful
12:28:53 Connecting on connection ServiceManager, server (LOCAL)\APP, as user sa
12:28:53 Connection successful
12:28:54 Connecting on connection Vehicle, server (LOCAL)\APP, as user sa
12:28:54 Connection successful
12:28:55 Connecting on connection UserStore, server (LOCAL)\APP, as user sa
12:28:55 Connection successful
12:28:55 Connecting on connection master, server (LOCAL)\APP, as user sa
12:28:55 Connection successful
12:28:55 Connecting on connection Feedback, server (LOCAL)\APP, as user sa
12:28:55 Connection successful
12:28:55 Done processing DB connections
~~~~~~
Create Vehicle tables and fill with information... (looks same for Core, ServiceManager, UserStore and Feedback)

12:50:19 ---OnSQLComponentInstalled(SQL_(1)_Vehicle_DropDb)

12:50:19 ---OnIISComponentInstalled(SQL_(1)_Vehicle_DropDb)

12:50:20 ---OnSQLComponentInstalled(SQL_(2)_Vehicle_CreateDb)

12:50:27 ---OnIISComponentInstalled(SQL_(2)_Vehicle_CreateDb)

12:50:28 ---OnSQLComponentInstalled(SQL_(3)_Vehicle_InitLoad)

12:50:32 ---OnIISComponentInstalled(SQL_(3)_Vehicle_InitLoad)


Version 8 patch log...

Start Update on Version 8 computer.
09:37:33 ---FEATURE_SQLExpress_Installed()
09:37:33 ***DIFFERENTIAL MEDIA***

BUT HERE IS SOMETHING FISHY, THERE SHOULD BE A LOG LINE SAYING
---OnSQLServerInitialize( 1 ), WHY ISNT IT CALLED?

~~~~~~
Vehicle database exists, so clear it and fill with new values... new CreateDB and new InitLoad is in package...

09:41:29 ---OnSQLComponentInstalled(SQL_(1)_Vehicle_DropDb)

09:41:34 ---OnIISComponentInstalled(SQL_(1)_Vehicle_DropDb)

09:41:34 ---OnSQLComponentInstalled(SQL_(2)_Vehicle_CreateDb)

09:41:35 ---OnIISComponentInstalled(SQL_(2)_Vehicle_CreateDb)

09:41:35 ---OnSQLComponentInstalled(SQL_(3)_Vehicle_InitLoad)

09:41:36 ---OnIISComponentInstalled(SQL_(3)_Vehicle_InitLoad)


The databases arent updated but the same components are run (except of OnSQLServerInitialize), why isnt that one called in updates in Version 8 but it is in both version 6 and 7 (and before then)... I am using basicly the same installshield project since then (different versions so it has been converted by IS itself)...

I hope that I have kept your interest in such a long post, but I am trying to give you as much information as possible to be able to solve the issue...

I will work on this problem for another bunch of hours, and if (or should I say when) I find the problem I will give you the solution...

// BR Per
0 Kudos
Diofantos
Level 3

ISNewone wrote:
Are you sure inside OnSQLServerInitialize, that the SQL server could be logged in ?

Also, make sure you turn on the "SQL Server And Windows Authentication mode" option.

If all failed, try look at the log file for error.



I have now found the problem... Thanx for reminding me about OnSQLServerInitialize...

My problem was that I only called it on full installations (my DVDs)... I now moved the call outside that function, so that OnSQLServerInitialize is called in both full releases and in patches and now everything seems to work ok.

Thanx for all the help!!! And I hope that this will help someone in the future...

// Per
0 Kudos
ISNewone
Level 3

You said you were using the IS 12 for version 6 and 7 (those work) and version 8 is using IS 2008. Since I am not familiar with IS 2008 so I couldn't tell if there is any difference between it and IS12.

Why don't you try to build the version 8 using Is 12 and see if that works?

Also the code after OnSQLComponentInstalled is compiled with the "#ifndef _UPDATE", are you sure that UPDATE is not defined udner version 8 somewhere?
0 Kudos