在 InstallShield 项目中使用安装脚本创建 SQL 连接
Create SQL connection using Install Script in InstallShield project
在 InstallShiled 安装项目中,我们有特定的要求,我们需要验证给定的 SQL 服务器上是否存在任何特定的数据库。
为此,我们使用下面的安装脚本:
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;
使用上面的安装脚本会出现以下错误:
---------------------------
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
---------------------------
知道我做错了什么吗?
在详细挖掘之后,我从 here 找到了解决这个问题的方法。
对于非 TLS 1.2
szConnString = "Provider=SQLOLEDB;"
szConnString = szConnString + "data source=SQLServerName;"
szConnString = szConnString + "Initial Catalog=master;"
szConnString = szConnString + "Integrated Security=SSPI"
对于 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
对于 TLS 1.2 来说是最佳解决方案,因为它在两种环境中都可以工作。
Microsoft 在今年 2018 年初发布了新的驱动程序 MSOLEDBSQL,并将继续仅提供此驱动程序的更新。
在 InstallShiled 安装项目中,我们有特定的要求,我们需要验证给定的 SQL 服务器上是否存在任何特定的数据库。
为此,我们使用下面的安装脚本:
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;
使用上面的安装脚本会出现以下错误:
---------------------------
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
---------------------------
知道我做错了什么吗?
在详细挖掘之后,我从 here 找到了解决这个问题的方法。
对于非 TLS 1.2
szConnString = "Provider=SQLOLEDB;"
szConnString = szConnString + "data source=SQLServerName;"
szConnString = szConnString + "Initial Catalog=master;"
szConnString = szConnString + "Integrated Security=SSPI"
对于 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
对于 TLS 1.2 来说是最佳解决方案,因为它在两种环境中都可以工作。
Microsoft 在今年 2018 年初发布了新的驱动程序 MSOLEDBSQL,并将继续仅提供此驱动程序的更新。