Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Updating a image tables from a master on an offsite Server


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0 Threads: [ Previous | Next ]
Donald Bossen

Posts: 81
Registered: 2/3/02
Updating a image tables from a master on an offsite Server  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 25, 2017 3:13 PM
This code is being run from a service that updates serval files from a master file on a server. My problem it runs once clear through but a day later it fails and gives me no hint of why it is failing it exits the service. if I restart the service runs for one day the next it stops at this function. When comment out the service runs for days with out stopping Maybe some one can show me what I have Missed.
Thanks in advance
Donald S. Bossen

Procedure ImageImport;
var
partNo : String;
fDate : TDateTime;
LDate : TDateTime;
FDbl : Double;
LDbl : Double;
Msg : String;

function ConnectToSqlP21(var Msg : String) : Boolean;
var
Server : String;
DbAcc : Boolean;
cntStr : String;
Ok : Boolean;

function ConnectToJBI(Server : String) : boolean;
var
cntStr : String;
begin
if not ConnectionJBI.Connected then
begin
ConnectionJBI.Connected := False;
CntStr := cGetDecodedText('kIxG88cBF66e85ZIvUBtFb6gUHx5IIfOd3bSAFYeX0tjNskXdLrXw7yWPaQO58V6',Code);
CntStr := CntStr + cGetDecodedText('USXyUvAAd2TRKLz74ktmB44B5Bfe5BMbiuEdjz7rshIZK6yeDz+rvbqGJFJ+SMuT8xk=',Code);
CntStr := CntStr + cGetDecodedText('Pr44eaVQpZ17UZSGARSU4MQkfKcpr90Yf6a1uHBYSQXKJnodkZSXl+ePfiYKBYdf3qP0LjnScGw0GRhUdL8=',Code);
CntStr := CntStr + cGetDecodedText('5zJwl6AzSK+RxT+ZF2blj0gd9UMNI7krIttA/18otz+j46xcFzSq15z7czI5euvu',Code);
if ReadIniBoolean(IniCfg,'Source','TestDb',False) then
CntStr := CntStr + cGetDecodedText('be4iSrvdKlLv2DKQkxCqTwpKQAW6NWnm+pWqkDSSz7JTn1pUs3a9RtR8O3tSubdL65k=',Code)//JBI2
else
CntStr := CntStr + cGetDecodedText('nItsfGBQD21EdjpiTpurqkaZI6B7xi8YpWQcKZLlwD5OUMr2Y5/XatC65IE4Sguz',Code);
CntStr := CntStr + cGetDecodedText('Kvzcffk1bplH/XNzLzuMI+EHVtfXCysFL8cFGsJ9gFg=',Code)+Server+';';
CntStr := CntStr + cGetDecodedText('Yylj/Sh6OBrtdBm09IFdDkxEqJZX9ds26FD8b4GIUVPnIkfbI2J8N77PHvpCQrqtF+05yw==',Code);
ConnectionJBI.ConnectionString := CntStr;
try
ConnectionJBI.Connected := True;
if ConnectionJBI.Connected then
result := True
else
begin
result := False;
Msg := 'Unable to Connect to JBI Database Bad Ip or Connection Missing';
end;
except
result := False; // Exception fired in connecting to JBI
Msg := 'Unable to Connect to JBI Database Bad Ip or Connection Missing';
end
end
else
result := True; // Allready conected to JBI Database
end;
function SelectRank(Server : String) : boolean;
var
Sql : WideString;
begin
if ConnectToJbi(Server) then
begin
TblRank.Active := False;
Sql := ' select *';
Sql := Sql + ' from labels_rank_rates';
TblRank.CommandText := Sql;
TblRank.Active := True;
if TblRank.RecordCount > 0 then
result := True
else
begin
result := False;
Msg := 'Selection Failed For Login Info in JBI Table Count = 0';
end;
end
else
result := False;
end;
begin
msg := '';
Ok := True;
if not ConnectionActivant.Connected then
begin
DbAcc := ReadIniBoolean(IniCfg,'Source','AcctDb',False);
server := PWideChar(IniGetDecodeText('Source','Server','yawara'));
if Ok then
begin
if SelectRank(Server) then
begin
if Not ConnectionActivant.Connected then
begin
CntStr := 'Provider=SQLOLEDB.1;';
CntStr := CntStr + cGetDecodedText('L2e8TR0a6Roqn2N88k6POCqyTeYhoekqqD63cGPH5Ge10IZKL4Yi1y0pF0vgVD69',Code);//
CntStr := CntStr + cGetDecodedText('WaI2I1OtwD0yTMZTagbN4/t2PEY8/55UcQn+zeyCGro+iN/ZSlugL4o2xf/MstauO18=',Code);//
CntStr := CntStr + 'Persist Security Info=True;';
if DbAcc then
CntStr := CntStr + 'Initial Catalog='+TblRank.FieldByName('sql_database_accounting').AsString+';'
else
CntStr := CntStr + 'Initial Catalog='+TblRank.FieldByName('sql_database').AsString+';';
CntStr := CntStr + 'Data Source='+Server+';';
CntStr := CntStr + 'Extended Properties="";';
CntStr := CntStr + 'Use Procedure for Prepare=1;';
CntStr := CntStr + 'Auto Translate=True;';
CntStr := CntStr + 'Packet Size=4096;';
CntStr := CntStr + 'Workstation ID=DSBOSSEN;';
ConnectionActivant.ConnectionString := CntStr;
try
ConnectionActivant.Connected := True;
if ConnectionActivant.Connected then
begin
result := True;
end
else
begin
result := False;
Msg := 'Unable to Connect to Prophet 21 Database Bad Ip or Connection Missing';
end;
except
result := False;
Msg := 'Unable to Connect to Prophet 21 Database Bad Ip or Connection Missing';
end;
end
else
result := True;
end
else
result := False;
end
else
begin
msg := 'NewPassword has be canceled';
result := False;
end;
end
else
result := True; // we are still conected to the sql database
end;

function FindNwP : Boolean;
var
Fac : String;
Sql : WideString;
begin
if SelectDataWhere(ConnectionScoreLocal,TblConfig,Msg,'Config','sls_no = ''EFAC''') then
begin
fac := TblConfig.FieldByName('fac_code').AsString;
TblNwP.Active := False;
Sql := ' select *';
Sql := Sql + ' from ScoreNw_Picture_Date';
Sql := Sql + ' where fac_code = '+Fac;
TblNwP.CommandText := Sql;
TblNwP.Active := True;
if TblNwP.RecordCount > 0 then
result := True
else
result := False;
end
else
result := False;
end;

function GetNwpDate : TDateTime;
var
Fac : String;
Sql : WideString;
begin
if SelectDataWhere(ConnectionScoreLocal,TblConfig,Msg,'Config','sls_no = ''EFAC''') then
begin
fac := TblConfig.FieldByName('fac_code').AsString;
TblNwP.Active := False;
Sql := ' select *';
Sql := Sql + ' from ScoreNw_Picture_Date';
Sql := Sql + ' where fac_code = '+Fac;
TblNwP.CommandText := Sql;
TblNwP.Active := True;
if TblNwP.RecordCount > 0 then
result := TblNwP.FieldByName('picture_date').AsDateTime
else
result := 0;
end
else
result := 0;
end;

begin
ConnectionScoreImport.Connected := False;
ConnectionScoreImage1.Connected := False;
ConnectionScoreImage2.Connected := False;
TblImage.Active := False;
if ConnectToSqlP21(Msg) then
FDate := GetNwpDate;
if SelectDataWhere(ConnectionScoreImport,TblImage,Msg,'Picture','') then
begin
SelectDataWhere(ConnectionScoreImage1,TblImage1,Msg,'Picture','');
if SelectDataWhere(ConnectionScoreImage2,TblImage2,Msg,'Picture','') then
begin
TblImage.First;
while not TblImage.Eof do
begin
PartNo := TblImage.FieldByName('part_no').AsString;
try
FDate := TblImage.FieldByName('img_date').AsDateTime;
FDbl := Double(FDate);
if SelectDataWhere(ConnectionScoreImage1,TblImage1,Msg,'Picture','part_no = '''+partno+'''') then//TblImage1.Locate('Part_no',PartNo,[]) then
begin
LDate := TblImage1.FieldByName('img_date').AsDateTime;
LDbl := Double(Ldate);
if FDbl > LDbl then
begin
TblImage1.Edit;
TblImage1.FieldByName('image').Assign(TblImage.FieldByName('image'));
TblImage1.FieldByName('Img_Date').AsDateTime := FDate;
end;
end
else if SelectDataWhere(ConnectionScoreImage2,TblImage2,Msg,'Picture','part_no = '''+partno+'''') then
begin
LDate := TblImage2.FieldByName('img_date').AsDateTime;
if FDate < LDate then
begin
TblImage2.Edit;
TblImage2.FieldByName('image').Assign(TblImage.FieldByName('image'));
TblImage2.FieldByName('Img_Date').AsDateTime := FDate;
end;
end
else
begin
TblImage2.Insert;
TblImage2.FieldByName('image').Assign(TblImage.FieldByName('image'));
TblImage2.FieldByName('Part_No').AsString := UpperCase(PartNo);
TblImage2.FieldByName('Img_Date').AsDateTime := FDate;
end;
except
on E: Exception do
begin
end;
end;
TblImage.Next;
end;
TblImage1.UpdateBatch;
TblImage2.UpdateBatch;
TblImage.Active := False;
if ConnectToSqlP21(Msg) then
begin
if FindNwP then
begin
TblNwp.Edit;
TblNwP.FieldByName('picture_date').AsDateTime := FDate;
TblNwp.Post;
end;
end;
end;
end;
end;
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02