在InstallShiled安装项目中,我们需要在给定的SQL Server上验证是否存在任何特定的DataBase。
为此,我们使用以下安装脚本:
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
---------------------------
知道我在这里做错了什么吗?
答案 0 :(得分:4)
在详细挖掘后,我从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是最佳解决方案,因为它在两种环境中都有效。
答案 1 :(得分:0)
Microsoft于2018年初发布了新的驱动程序 MSOLEDBSQL ,并将继续仅提供此驱动程序的更新。