ch_eng
Flexera beginner

Re: Installscript execute SQL script and return values

Rishi,

Do you have any connections created in the "SQL Scripts" section of "Server Configuration" ? I vaguely remember needing to have one created (even if not used) so InstallShield will add some required behind-the-scenes stuff.




HTH
0 Kudos
hrushikesh1600
Pilgrim

Re: Installscript execute SQL script and return values

Yup, I have three, in fact. And I can verify that I am able to successfully authenticate to those connections before running the SELECT script that I am trying to run.

EDIT: I see you have a script to create a SQL user? Would you mind sharing some pointers on how you're using that? Like what dialog do you use to get the credentials for the admin user who will create the additional user and how you invoke this script later?

Thanks!
0 Kudos
ch_eng
Flexera beginner

Re: Installscript execute SQL script and return values

Rishi,

I remembered that I do have one InstallScript MSI project that uses a SQL database connection. At the top of the .rul script for every dialog that uses the SQL connection, it has this block for the #includes (same as above):

#include "ISRT.h"
//#include "ISRTPriv.h" // this is included in the original file but breaks when included in the custom file

#ifdef SQLRT_OBL
#include "SQLRT.h"
#elif SQLCONV_OBL
#include "SQLConv.h"
#endif


and near the top of the "begin" section of every .rul script in the ShowDialog function, it has this block (same as above):

if (!g_bSQLRTInitialized) then
//this fails the first time because of trying to customize this dialog? (because can't include ISRTPriv.h ?)
//return ISERR_GEN_FAILURE;
else
//(re)run the required SQLRTInitialize2 function and rerun the test
SQLRTInitialize2();
if (!g_bSQLRTInitialized) then
return ISERR_GEN_FAILURE;
endif;
endif;

// ensure general initialization is complete
if (!bSdInit) then
SdInit();
endif;


This is a simplified version of what happens when I connect via ADODB via InstallScript to get a value returned. This assumes the query is in the form "SELECT something AS Value FROM sometable".
set objADODBConnection = CoCreateObject( "ADODB.Connection" );
objADODBConnection.ConnectionString = szADODBConnectionString;
objADODBConnection.Open;

set objADODBCommand = CreateObject( "ADODB.Command" );
objADODBCommand.ActiveConnection = objADODBConnection;
objADODBCommand.CommandText = szSQLCode;
set objReader = objADODBCommand.Execute();
if !objReader.EOF then
svResult = objReader.Fields( "Value" ).Value;
endif;
objReader.Close();


Other than that, the only thing I can suggest is to create a new blank InstallScript MSI project and try just adding the SQL functionality to it. It's been a long time since I've setup a new project with SQL connectivity, but I don't remember offhand having to manually do something like this: "In my build path, though, I do include "SQLRTConv.obl" library."

HTH and good luck!
0 Kudos
hrushikesh1600
Pilgrim

Re: Installscript execute SQL script and return values

Will do, my man! Thanks for all your help.

Rishi
0 Kudos