title: Storing values in variables using Execute SQL Task Object
body: <p>I have an execute sql task defined in my package which will execute a stored procedure. When the stored procedure is executed it will return user credential. I have to store the credential in a variables and then use these credentials in a new script task.</p>
  
  <p>The following is what I have tried so far.</p>
  
  <p><strong>STEP 1 - I have created SQL task</strong></p>
  
  <p><em>On General TAB  set following properties:</em></p>
  
  <pre><code>Resultset: Single row
  connectionType: OLE DB
  Connection:SourceDestination
  SQLSourceType:DirectInput
  SQLStatement: Execute dbo.GetLoginInfo1
  ByPassPrepare = False
  </code></pre>
  
  <p><strong>STEP 2 - Parameter Mapping Tab</strong></p>
  
  <pre><code>Variable Name = User::DatabaseUserName
  Direction = Output
  Data Type = NVarchar
  Parameter Name = @UserId
  Parameter Size = 50
  </code></pre>
  
  <p><strong>STEP 3 - Result Set tab</strong> </p>
  
  <pre><code>Result Name = 0
  Variable Name = User::DatabaseUserName
  </code></pre>
  
  <p>When I executed the task I got following errors.</p>
  
  <pre><code>[Execute SQL Task] Error: Executing the query "EXECUTE [dbo].[GetUserLoginInfo1]"
  failed with the following error: "Value does not fall within the expected range."
  Possible failure reasons: Problems with the query, "ResultSet" property not set
  correctly, parameters not set correctly, or connection not established correctly
  </code></pre>
  
  <p>When I debug I got to see following information:
  Break ON Pre execute:</p>
  
  <pre><code>User::DatabaseUserName = {Hi}
  </code></pre>
  
  <p>Break ON Post Execute: (error happens but the values gets chanage)</p>
  
  <pre><code>User::DatabaseUserName = {User1}
  </code></pre>
  
  <p>Sorry just forgot to mention the creation of variables. I have create one variable as listed below.</p>
  
  <pre><code>Name = DatabaseUserName
  Scope = Package1
  Datatype = String
  Value = Hi
  </code></pre>
  
  <p>The below mentioned is the stored procedure that I have used.</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[GetUserLoginInfo1]
  AS
  BEGIN
      SELECT userid AS userid
      FROM login_credentials 
      WHERE servername= 'server1'
  END
  </code></pre>
  
  <p>I have tried and read lot many sites but I am still facing the problem.This is my second day on it and have to resolve it before tomorrow morning so any help will be really appreciated.</p>