installshieldtls1.2installscriptinstallscript-msiinstallshield-2016

Create SQL connection using Install Script in InstallShield project


In InstallShiled setup project we have certain requirement that we need to validate any specific DataBase is exist or not on given SQL Server.

For that we are using below Install Script:

szADOConnObjID = "ADODB.Connection";
set pADOConnObj = CreateObject(szADOConnObjID); 

szConnString = "driver={SQL Server};"; // For TLS 1.2 Only use driver={SQL Server Native Client 11.0};
szConnString = szConnString + "server=HPSDEV67;";
szConnString = szConnString + "Initial Catalog=master;";
szConnString = szConnString + "Integrated Security=True";
MessageBox("SQL Connection String: " + szConnString, INFORMATION);

try
    MessageBox("Trying with Windows Authentication first", INFORMATION);
    if (pADOConnObj.State==0)then 
        pADOConnObj.Open(szConnString);
        MessageBox("Connection Success", INFORMATION);
    endif;  
catch
    MessageBox("Windows Authentication Catch",INFORMATION);
    MessageBox(Err.Description , SEVERE);
endcatch;

With above Install Script it gives below error:

---------------------------
Sample SQL Connect - InstallShield Wizard
---------------------------
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
---------------------------
OK   
---------------------------

Any idea what am I doing something wrong here?


Solution

  • After digging in detail I found fix for this from here.

    For Non-TLS 1.2

    szConnString = "Provider=SQLOLEDB;"
    szConnString = szConnString + "data source=SQLServerName;"
    szConnString = szConnString + "Initial Catalog=master;"
    szConnString = szConnString + "Integrated Security=SSPI"
    

    For TLS 1.2

    szConnString = "Provider=SQLNCLI11;"
    szConnString = szConnString + "SERVER=SQLServerName;"
    szConnString = szConnString + "database=master;"
    szConnString = szConnString + "Trusted_Connection=Yes"
    msgbox "SQL Connection String: " + szConnString, INFORMATION
    

    For TLS 1.2 is best solution because it's working in both environment.