【发布时间】: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