title: Recent Failures on Delphi TADOStoredProc / D6 and RAD Studio XE2
body: <p>Thanks to any that can provide some assistance...</p>
  
  <p><strong>Background:</strong></p>
  
  <p>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.  </p>
  
  <p>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.)  </p>
  
  <p>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.</p>
  
  <p><strong>Where to go?</strong></p>
  
  <ul>
  <li>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.</li>
  <li>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.  </li>
  </ul>
  
  <p><strong>Code Example</strong></p>
  
  <pre><code>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=&lt;testPwd&gt;;Persist Security Info=True;User ID=&lt;testUser&gt;;Initial Catalog=&lt;myDB&gt;;Data Source=&lt;myServer&gt;';
      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
  </code></pre>
  
  <p>Thanks for any help you can provide.</p>