我们有同步一些数据库(sqlserver)的应用程序。技术员数据库(SQLExpress 2008 32 位)和服务器端 SqlServer 2008 R2 64 位。
在同步应用程序中我对一些脚本进行同步。从技术人员到服务器的数据库。现在我收到类似 [DBNETLIB][ConnectionWrite (send()).] 的错误。
我已经记录了一些关于错误的日志
--21/10/2013 11:05:12------------Update on t_intervention_mission--------------------------------
Old Values:
ID=0,RowID={06938E13-F068-437D-A454-3E17B4C7CCC6},IntCardID= NULL,IntCardRowID={69D86DD9-55E5-450F-BC72-93FE2DB5BA1E},MissionID= NULL,MissionRowID={7D1F046F-C82A-42AA-9712-00D4F7FEC5BF},Duration=CONVERT(DATETIME,'1899-12-30 00:00:00.000', 102),Number=1,InCalculation=0,KindID= NULL,KindRowID={D2BD32AD-5926-4AF6-9258-F52F453800A8},WorkTime=0,PayerReference='r',WorkOut=0,ImmovableProperty=1,VatPercent=21,DurationChange=0,DefaultMissionPrice=0,ProductCount=0,DeliverProductPrice=0,DeliverWorkPrice=0,DeliverTransportPrice=0,DeliverMissionPrice=0,DeliverTotalPrice=0,ActiveProductPrice=0,ActiveWorkPrice=0,ActiveTransportPrice=0,ActiveMissionPrice=0,ActiveTotalPrice=0,TariffID= NULL,TariffRowID= NULL,WorkCostPercent=0,WorkCostPlus=0,WorkAmountPercent=0,WorkAmountPlus=0,ProductAmountPercent=0,ProductAmountPlus=0,TransportCostPercent=0,TransportCostPlus=0,TransportAmountPercent=0,TransportAmountPlus=0,MissionAmountPercent=0,MissionAmountPlus=0,DateCreate=CONVERT(DATETIME,'2013-10-21 11:02:36.083', 102),DateChange=CONVERT(DATETIME,'2013-10-21 11:05:00.620', 102),WorkStationCreate='SIX001',WorkStationChange='SIX001',ContractPrice=0,IsSafeCondition= NULL
Script:
update t_intervention_mission set PayerReference='r',DateChange=CONVERT(DATETIME,'2013-10-21 11:05:00.620', 102) where RowID = '{06938E13-F068-437D-A454-3E17B4C7CCC6}'
--ERROR--EOleException--------------------------------------------------------------------
[DBNETLIB][ConnectionWrite (send()).]Algemene netwerkfout. Raadpleeg de netwerkdocumentatie
On script: update t_intervention_mission set PayerReference='r',DateChange=CONVERT(DATETIME,'2013-10-21 11:05:00.620', 102) where RowID = '{06938E13-F068-437D-A454-3E17B4C7CCC6}'
Connection:AdoConnectionServer
Number = -2147467259
NativeError = 11
Source = Microsoft OLE DB Provider for SQL Server
Description = [DBNETLIB][ConnectionWrite (send()).]Algemene netwerkfout. Raadpleeg de netwerkdocumentatie.
Helpfile =
SQLState = HY018
ConnectionTimeOut = 60
CommandTimeout = 120
--21/10/2013 11:05:41----------------------------------------------------------------
在日志中,脚本想要进行更新。我还在 sqlserver 的命令提示符中设置了一个永恒的 ping。当脚本执行更新时,ping 会超时。
仅当我有移动宽带连接时才会出现此错误。当技术人员到达公司时,笔记本电脑会找到公司的 wifi 并且可以完成脚本。该错误仅发生在移动宽带连接中。
function TLogFile.SqlExec (StrSql : String; AdoConnection : TADOConnection; ARec: _RecordSet): Integer;
begin
Result := 0;
try
ARec := AdoConnection.Execute(StrSql, cmdText);
except
on E : Exception do
begin
E.Message:= E.Message+ craConstant.CRLF+
'On script: '+StrSql+ craConstant.CRLF+
'Connection:'+ AdoConnection.Name;
if (E.ClassType = EOleException) and (AdoConnection.Errors.Count > 0) then
begin
E.Message:= E.Message+ craConstant.CRLF+
'Number ='+IntToStr(AdoConnection.Errors[0].Number)+CRLF+
'NativeError ='+IntToStr(AdoConnection.Errors[0].NativeError)+CRLF+
'Source ='+AdoConnection.Errors[0].Source+CRLF+
'Description ='+AdoConnection.Errors[0].Description+CRLF+
'Helpfile ='+AdoConnection.Errors[0].HelpFile+CRLF+
'SQLState ='+AdoConnection.Errors[0].SQLState;
end;
self.HndException:= E;
Result := -1;
raise;
end;
end;
end;
我对函数 sqlexec 做了一些更改:
function TLogFile.SqlExec (StrSql : String; AdoConnection : TADOConnection): Integer;
var
oQuerySql: TADOQuery;
begin
Result := 0;
oQuerySql:= TADOQuery.Create(Nil);
try
oQuerySql.Connection:= AdoConnection;
oQuerySql.CommandTimeout:= AdoConnection.CommandTimeout;
oQuerySql.SQL.Add(StrSql);
try
oQuerySql.ExecSQL;
except
on E : Exception do
begin
E.Message:= E.Message+ craConstant.CRLF+
'On script: '+StrSql+ craConstant.CRLF+
'Connection:'+ AdoConnection.Name;
if (E.ClassType = EOleException) and (AdoConnection.Errors.Count > 0) then
begin
E.Message:= E.Message+ craConstant.CRLF+
'Number = '+IntToStr(AdoConnection.Errors[0].Number)+CRLF+
'NativeError = '+IntToStr(AdoConnection.Errors[0].NativeError)+CRLF+
'Source = '+AdoConnection.Errors[0].Source+CRLF+
'Description = '+AdoConnection.Errors[0].Description+CRLF+
'Helpfile = '+AdoConnection.Errors[0].HelpFile+CRLF+
'SQLState = '+AdoConnection.Errors[0].SQLState+CRLF+
'ConnectionTimeOut = '+IntToStr(AdoConnection.ConnectionTimeout) +CRLF+
'CommandTimeout = '+IntToStr(AdoConnection.CommandTimeout);
end;
self.HndException:= E;
Result := -1;
raise;
end;
end;
finally
FreeAndNil(oQuerySql);
end;
end;
此更改可以使用 3 天,现在我在插入脚本上返回错误,例如
--21/10/2013 14:11:05------------Insert on t_intervention_mission----------------------------------------------------
Old Values:
ID=0,RowID={53C5780D-B683-45C9-B942-018091DD0435},IntCardID= NULL,IntCardRowID={0709FB3B-1CDD-4E2B-BAC6-4FB6A952F788},MissionID= NULL,MissionRowID={C24234F2-DD1F-4B3B-B81D-3D13384CC573},Duration=CONVERT(DATETIME,'1899-12-30 00:20:00.000', 102),Number=1,InCalculation=0,KindID= NULL,KindRowID={77387E4C-604A-4653-B490-38A6B9C5A8E5},WorkTime=0,PayerReference= NULL,WorkOut=1,ImmovableProperty=1,VatPercent=0,DurationChange=0,DefaultMissionPrice=0,ProductCount=0,DeliverProductPrice=0,DeliverWorkPrice=0,DeliverTransportPrice=0,DeliverMissionPrice=0,DeliverTotalPrice=0,ActiveProductPrice=0,ActiveWorkPrice=13.54,ActiveTransportPrice=11.01,ActiveMissionPrice=0,ActiveTotalPrice=24.55,TariffID= NULL,TariffRowID={DADB09D9-A760-4213-98AA-47E090EAB1FD},WorkCostPercent=0,WorkCostPlus=0,WorkAmountPercent=30,WorkAmountPlus=0,ProductAmountPercent=0,ProductAmountPlus=0,TransportCostPercent=0,TransportCostPlus=0,TransportAmountPercent=0,TransportAmountPlus=0,MissionAmountPercent=0,MissionAmountPlus=0,DateCreate=CONVERT(DATETIME,'2013-09-02 08:37:54.530', 102),DateChange=CONVERT(DATETIME,'2013-09-02 08:38:06.460', 102),WorkStationCreate='SIX001',WorkStationChange='SIX001',ContractPrice=0,IsSafeCondition= NULL
Script:
insert into t_intervention_mission (RowID,IntCardRowID,MissionRowID,Duration,Number,InCalculation,KindRowID,WorkTime,WorkOut,ImmovableProperty,VatPercent,DurationChange,DefaultMissionPrice,ProductCount,DeliverProductPrice,DeliverWorkPrice,DeliverTransportPrice,DeliverMissionPrice,DeliverTotalPrice,ActiveProductPrice,ActiveWorkPrice,ActiveTransportPrice,ActiveMissionPrice,ActiveTotalPrice,TariffRowID,WorkCostPercent,WorkCostPlus,WorkAmountPercent,WorkAmountPlus,ProductAmountPercent,ProductAmountPlus,TransportCostPercent,TransportCostPlus,TransportAmountPercent,TransportAmountPlus,MissionAmountPercent,MissionAmountPlus,DateCreate,DateChange,WorkStationCreate,WorkStationChange,ContractPrice) values ('{53C5780D-B683-45C9-B942-018091DD0435}','{0709FB3B-1CDD-4E2B-BAC6-4FB6A952F788}','{C24234F2-DD1F-4B3B-B81D-3D13384CC573}',CONVERT(DATETIME,'1899-12-30 00:20:00.000', 102),1,0,'{77387E4C-604A-4653-B490-38A6B9C5A8E5}',0,1,1,0,0,0,0,0,0,0,0,0,0,13.54,11.01,0,24.55,'{DADB09D9-A760-4213-98AA-47E090EAB1FD}',0,0,30,0,0,0,0,0,0,0,0,0,CONVERT(DATETIME,'2013-09-02 08:37:54.530', 102),CONVERT(DATETIME,'2013-09-02 08:38:06.460', 102),'SIX001','SIX001',0)
--ERROR--EOleException--------------------------------------------------------------------
[DBNETLIB][ConnectionWrite (send()).]Algemene netwerkfout. Raadpleeg de netwerkdocumentatie
On script: insert into t_intervention_mission (RowID,IntCardRowID,MissionRowID,Duration,Number,InCalculation,KindRowID,WorkTime,WorkOut,ImmovableProperty,VatPercent,DurationChange,DefaultMissionPrice,ProductCount,DeliverProductPrice,DeliverWorkPrice,DeliverTransportPrice,DeliverMissionPrice,DeliverTotalPrice,ActiveProductPrice,ActiveWorkPrice,ActiveTransportPrice,ActiveMissionPrice,ActiveTotalPrice,TariffRowID,WorkCostPercent,WorkCostPlus,WorkAmountPercent,WorkAmountPlus,ProductAmountPercent,ProductAmountPlus,TransportCostPercent,TransportCostPlus,TransportAmountPercent,TransportAmountPlus,MissionAmountPercent,MissionAmountPlus,DateCreate,DateChange,WorkStationCreate,WorkStationChange,ContractPrice) values ('{53C5780D-B683-45C9-B942-018091DD0435}','{0709FB3B-1CDD-4E2B-BAC6-4FB6A952F788}','{C24234F2-DD1F-4B3B-B81D-3D13384CC573}',CONVERT(DATETIME,'1899-12-30 00:20:00.000', 102),1,0,'{77387E4C-604A-4653-B490-38A6B9C5A8E5}',0,1,1,0,0,0,0,0,0,0,0,0,0,13.54,11.01,0,24.55,'{DADB09D9-A760-4213-98AA-47E090EAB1FD}',0,0,30,0,0,0,0,0,0,0,0,0,CONVERT(DATETIME,'2013-09-02 08:37:54.530', 102),CONVERT(DATETIME,'2013-09-02 08:38:06.460', 102),'SIX001','SIX001',0)
Connection:AdoConnectionServer
Number =-2147467259
NativeError =11
Source =Microsoft OLE DB Provider for SQL Server
Description =[DBNETLIB][ConnectionWrite (send()).]Algemene netwerkfout. Raadpleeg de netwerkdocumentatie.
Helpfile =
SQLState =HY018
--21/10/2013 14:11:37----------------------------------------------------------------
我去找地板上的技术员。我使用旧函数 TLogFile.SqlExec (StrSql : String; AdoConnection : TADOConnection; ARec: _RecordSet): Integer; 并且脚本没有给我错误。AdoConnection.Execute(StrSql, cmdText) VS oQuerySql.ExecSQL 有什么问题;adoconnection 和脚本在一个线程中完成。
在较旧的笔记本电脑(Windows XP)上,我没有这个问题。仅适用于装有 Windows7 的新笔记本电脑。
如果有人可以给我一些澄清或提示在哪里搜索问题。我会很感激的。“SQL Server Native Client 10.0”和“Microsoft OLE DB Provider for SQL Server”之间是否也有区别。
对于同步,我使用“Microsoft OLE DB Provider for SQL Server”