Thanks to any that can provide some assistance...
Background:
I have an application coded and still supported in Borland Delphi v6. Very recently I have had issues with the TADOStoredProc class failing to execute the stored procedure. This code had previously been stable for several years and had never been modified.
I can configure a timeout on the request, which is respected, however the stored procedure call never runs, even on a very long timeout. The application just hangs, or bails on a timeout exception. (I know the server is not overburdened and responds to other SQL SELECT requests originated by the same client.)
I know D6 is old. I do have a separate environment with Embarcadero RAD Studio XE2, where I managed to build the same project, and have the same issues still. ... Just to make sure.
Where to go?
- Please review the code provided, and see if there's a better way to do things. (Maybe the MSSQL interface is more picky, after a recent update?) I certainly welcome recommendations.
- Is there an alternate method I can plug into the app, that is reliable and doesn't require TADOStoredProc? I've done my digging, but haven't hit any good examples.
Code Example
function TImport.OpenHeader(DriverID: Integer, …, ScanStart: DateTime, ...): integer;
var
suid: integer;
jid: integer;
con : TADOConnection;
sp : TADOStoredProc;
begin
suid := getScanUnitID();
jid := deriveJobID(ScanStart);
con := TADOConnection.Create(nil);
con.LoginPrompt := false;
con.ConnectionString := 'Provider=SQLOLEDB.1;Password=<testPwd>;Persist Security Info=True;User ID=<testUser>;Initial Catalog=<myDB>;Data Source=<myServer>';
con.CommandTimeout := 10;
con.KeepConnection := true;
con.Connected := true;
sp := TADOStoredProc.Create(nil);
sp.Connection := con;
sp.CommandTimeout := 10;
sp.ProcedureName := 'mon4_OpenHeader;1';
sp.Parameters.Refresh;
sp.Parameters.ParamByName('@ScanUnitID').Value := suid;
sp.Parameters.ParamByName('@JobID').Value := jid;
sp.Parameters.ParamByName('@DriverID').Value := DriverID;
//[…]
sp.Parameters.ParamByName('@Result').Direction := pdOutput; //returned from stored proc
sp.ExecProc;
Result := sp.Parameters.ParamByName('@Result').Value;
sp.Free;
con.Free;
end; // end OpenHeader(DriverID: Integer, …, ScanStart: DateTime, …): integer
Thanks for any help you can provide.