Install/Uninstall SQLNativeClient DB driver

Install/Uninstall SQL DB driver.
SQLNCLI.msi that is needed when you do connection to SQL database inside VBA.
One of my important functions to automate installation of SQLNCLi in the background using SQLNCLI.MSI that is expected to be ready to be used (both x86 or 64 bit versions).
This way the user don't get notified or prompted to install.
Used widely in my Excel/VBA tools that needs to have connection to online SQL DB ready.
Installer will also log the outcome into txt file next to msi file.
Needs oShellRun1, FixPath and GetPapa

What is this?



Original Work

Function SQLNativeClient_InstallDriver(Optional MSIPath = "C:\folder\sqlncli.msi")
    MSIPath2 = FixPath(GetPapa(MSIPath)) & "Log.txt"
    Shell1 = "msiexec /i """ & MSIPath & """ /qr IACCEPTSQLNCLILICENSETERMS=YES AddLocal=All /Log """ & MSIPath2 & """"
    SQLNativeClient_InstallDriver = oShellRun1( Shell1, MSIPath2 )
End Function

Function SQLNativeClient_UninstallDriver(Optional MSIPath = "C:\folder\sqlncli.msi")
    ' Returns 1 if SQL Native Client was uninstalled successfully, anything else if not
    ' msiexec /x "D:\ANmar.Systems\Projects.Individual\2015\Attempt5\Res\SQLNCLI11.x86\sqlncli.msi" /qr
    ' MSI1 = SettingRead("DBVar6") '    MSI1 = "sqlncli.msi"
    ' MSILoc1 = SettingRead("DBVar8")
    Shell1 = "msiexec /x """ & MSIPath & """ /qr "
    SQLNativeClient_UninstallDriver = oShellRun1(Shell1, MSILoc1)
'    If Return1 = 1 Then
'        MsgBox "Uninstalled !", vbInformation
'    Else
'        MsgBox "Error when uninstalling !", vbCritical
'    End If
End Function

Optional MSIPath = "C:\folder\sqlncli.msi"

Views 135

Downloads 23