【问题标题】:Connecting SQL Server 2012 with out part of the sql installed on the client连接 SQL Server 2012 与客户端上安装的部分 sql
【发布时间】:2017-01-27 03:45:27
【问题描述】:

我有 4 个。 2 有完整的设置 SQ Server 2012 设置,1 作为除了数据库设置之外的所有设置,1 根本没有 SQL 设置。带有 SQL 设置的 3 连接到我称为具有数据库设置的子服务器的那个。根本没有安装 SQL 的那个不连接会抛出异常。 这是我的连接字符串。

Provider=SQLNCLI11;Integrated Security="";Persist Security Info=False;User ID=sa;password=Xxxx1234;OLE DB Services=-2;Initial Catalog=score_data;Data Source=192.168.9.25,1433;Initial文件名=“”;数据包大小=4096;自动翻译=真;服务器SPN=“”;

这是我用于创建此字符串并连接的 Delphi 代码

function TFrmTb2.ConnectToSqlDB(Var DataBase : TADOConnection; Catalog : String; Var Msg : ShortString) : Boolean;
  var
    cntStr     : String;
  begin
    msg := '';
    CntStr := DataBase.Name;
    if not DataBase.Connected then
      begin
        if Not DataBase.Connected then
          begin
            with FrmTb2 do
              begin  //Edit ConfigHdwe2016Nw.Ini in tne Score2016NW Directory section SQL
                CntStr := 'Provider='+ReadIniStr(IniHdwe,'SQL','Provider')+';';//SQLNCLI11.1';//SQLNCLI10.1;';
                CntStr := CntStr + 'Integrated Security='+ReadIniStr(IniHdwe,'SQL','Integrated Security')+';';//"";';
                CntStr := CntStr + 'Persist Security Info='+ReadIniStr(IniHdwe,'SQL','Persist Security Info')+';';//False;';
                CntStr := CntStr + 'User ID='+ReadIniStr(IniHdwe,'SQL','User ID')+';';//shithead;';
                CntStr := CntStr + 'password='+ReadIniStr(IniHdwe,'SQL','password')+';';//shithead;';
                CntStr := CntStr + 'OLE DB Services='+ReadIniStr(IniHdwe,'SQL','OLE DB Services')+';';// -2;';
                CntStr := CntStr + 'Initial Catalog='+Catalog+';';
                CntStr := CntStr + 'Data Source='+ReadIniStr(IniHdwe,'SQL','Data Source')+';';//\SQLEXPRESS;';
                CntStr := CntStr + 'Initial File Name='+ReadIniStr(IniHdwe,'SQL','Initial File Name')+';';//"";';
                CntStr := CntStr + 'Packet Size='+ReadIniStr(IniHdwe,'SQL','Packet Size')+';';//4096;';
                CntStr := CntStr + 'Auto Translate='+ReadIniStr(IniHdwe,'SQL','Auto Translate')+';';//True;';
                CntStr := CntStr + 'Server SPN='+ReadIniStr(IniHdwe,'SQL','Server SPN')+';';//""';
              end;
//            ShowMessage(CntStr);
            DataBase.ConnectionString := CntStr;
            try
              DataBase.Connected := True;
              if DataBase.Connected then
                begin
//                  ShowMessage('After Conection');
                  result := True;
                end
              else
                begin
                  result := False;
                  ShowMessage('Unable to Connect to Score2016Nw Database Bad Ip or Connection Missing1');
                end;
            except
              result := False;
              ShowMessage('Unable to Connect to Score2016Nw Database Bad Ip or Connection Missing2');
            end;
          end
        else
         result := True;
      end
    else
      result := True; // we are still conected to the sql database
  end;

我的网络人员告诉我,Fire Fall 端口 1433 已打开(它是硬件线墙,我无权访问)。我已经在子服务器上检查并重新检查了 ip2 是否处于活动状态 = Yes;启用 = 是; IP 地址 = 255.255.255.0(子网掩码); TCP Port = 1433 and IPALL Dynamic Ports = ''(Blank) and TCP Port = 1433子服务器并连接到数据库。是否有任何工具可以用来查找问题,或者我需要在所有客户端上安装 SQL Server(多么痛苦)

【问题讨论】:

  • 当您说“引发异常”时,您确实需要告诉我们该异常是什么。我猜它告诉你它找不到提供者。
  • ShowMessage('Unable to Connect to Score2016Nw Database Bad Ip or Connection Missing2');就像我的代码一样。
  • 那是您自己的代码生成的自定义错误信息,对我们没有帮助。您正在捕获异常,为什么不阅读异常的消息并向我们报告它所说的内容?无论如何,我们不可能用您在问题中提供的内容复制您的确切错误,除了我在回答中描述的未安装的提供程序。
  • 不要猜测,参考实际异常。我几乎可以肯定,一旦你这样做了,你就会自己找出真正的原因。

标签: sql-server delphi


【解决方案1】:

您的连接字符串包含SQLNCLI11 作为其提供者。这意味着,您需要在这台机器上安装SQL Native Client 11,因为这就是它正在寻找的提供者。安装 SQL Server 时,它还会默认为您安装 SQL Native Client。但是在一台从未安装过 SQL 的机器上,你必须自己安装它。

或者,作为替代方案,您可以使用预装在 Windows 中的 OLE DB 驱动程序,而是使用 SQLOLEDB.1 作为提供程序。

【讨论】:

  • 就是它下载并安装了 SQLNCLI11 驱动程序,一切正常。 SQLOLEDB1 的问题在于 DateTime 和从 SQL 转换它们时存在问题
  • @Sbossen 有趣的是,我们公司使用 SQL OLE DB 驱动程序已有 10 多年了,并且对 DateTime 字段进行了很多的工作。你的意思是什么问题?
  • 当我使用 ado 连接从 sql 读取日期时间时,当我切换回 SQLNCLI11 时,我会得到一个无效的日期时间格式,没问题。如果您能找到来自 MS 的文档说明驱动程序何时更新并且问题出现在日期时间(请参阅上面的链接以安装 Sql Native Client 11,我查找了很多以找到安装 MSI)。我正在使用 Delphi XE6
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-20
  • 1970-01-01
相关资源
最近更新 更多