title: Getting Exception : The Size Property Has an Invalid Size Of 0
body: <p>i have created a method with a following signature;</p>
  
  <pre><code>public bool CheckEmployeeRegistrationNo(string registrationNo, DateTime timeIn, int createdBy,
      DateTime createdDate, int updatedBy, DateTime updatedDate)
  {
      ClsDatabaseManager dbManager = ClsDatabaseManager.InitializeDbManager();
  
      dbManager.CreateParameters(9);
      dbManager.AddParameters(0, "@RegistrationNo", registrationNo);
      dbManager.AddParameters(1, "@CreatedBy", createdBy);
      dbManager.AddParameters(2, "@CreatedDate", createdDate);
      dbManager.AddParameters(3, "@UpdatedBy", updatedBy);
      dbManager.AddParameters(4, "@UpdatedDate", updatedDate);
      dbManager.AddParameters(5, "@TimeIn", timeIn);
      dbManager.AddParameters(6, "@Name", EmployeeName, System.Data.ParameterDirection.Output);
      dbManager.AddParameters(7, "@GeneratedTimeIn", GeneratedTimeIn, System.Data.ParameterDirection.Output);
      dbManager.AddParameters(8, "@ImageUrl", ImageUrl, System.Data.ParameterDirection.Output);
  
      int result = -1;
      try
      {
          dbManager.Open();
          result = dbManager.ExecuteNonQuery("usp_EmployeeCheckRegNo");
          if (result &gt; 0)
          {
              EmployeeName = dbManager.Parameters[6].Value.ToString();
              GeneratedTimeIn = dbManager.Parameters[7].Value.ToDate();
              ImageUrl = dbManager.Parameters[8].Value.ToString();
          }
          dbManager.Dispose();
      }
      catch (Exception ex)
      {
          dbManager.Dispose();
          throw ex;
      }
  
      return (result != -1);
  
  }
  </code></pre>
  
  <p>While my stored procedure looks like;</p>
  
  <pre><code>ALTER PROC [dbo].[usp_EmployeeCheckRegNo]
  (
      @RegistrationNo nvarchar(50),
      @TimeIn Datetime,
      @CreatedBy INT,
      @CreatedDate datetime,
      @UpdatedBy INT,
      @UpdatedDate datetime,
      @Name nvarchar(50) OUT,
      @GeneratedTimeIn datetime OUT,
      @ImageUrl nvarchar(100) OUT
  )
  AS
  
  BEGIN
  
  if Exists 
  (
      select RegistationNo 
      FROM [Employe].Registration
      WHERE [RegistationNo] = @RegistrationNo
  )
      BEGIN
          INSERT INTO [Employe].[Attendance]
          (
              RegistrationNo,
              [TimeIn],
              [CreatedBy],
              [CreatedDate],
              [UpdatedBy],
              [UpdatedDate]
          )
          VALUES
          (
              @RegistrationNo,
              @TimeIn,
              @CreatedBy,
              @CreatedDate,
              @UpdatedBy,
              @UpdatedDate
          )
           SET @Name = (select er.Name FROM [Employe].[Registration] er
              WHERE er.[RegistationNo] = @RegistrationNo);
           SET @GeneratedTimeIn = (select a.TimeIn 
              FROM [Employe].Attendance a
              WHERE a.RegistrationNo = @RegistrationNo);
           SET @ImageUrl = (select er.[Image] 
              FROM [Employe].[Registration] er
              WHERE er.RegistationNo = @RegistrationNo);
      END
  ELSE
      return 0
  END
  </code></pre>
  
  <p>However, when i enter 2323 (value) in a textbox, and click on a button (on .aspx), i am getting an error. I also debug in visual studio. <br />
  The error is;
  <strong>String[6]: The Size Property Has an Invalid Size Of 0</strong> <br />
  Why i am getting this error at String 6 ? <br />
  Note: i am currently supplying null values to the parameters 6, 7, 8 becuase they are returned as outparamter.
  <img src="https://i.stack.imgur.com/AKYKQ.png" alt="Visual Studio Screen Shot">
  <br /></p>
  
  <p>While in sql server, i run the stored procedure and output the expected results; <br />
  <img src="https://i.stack.imgur.com/LgoIp.png" alt="enter image description here"></p>