Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 73927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:16:41+00:00 2026-05-10T20:16:41+00:00

When running the following code it leaves out one row. When I do a

  • 0

When running the following code it leaves out one row. When I do a files.Count it says there are 4 rows but there is no data stored for the 4th row. When I run the stored procedure from within SQL Manager it returns all 4 rows and all the data. Any help?

            List<File> files = new List<File>();             SqlConnection active_connection = new SqlConnection(m_connection_string);             SqlCommand cmd = new SqlCommand();             SqlDataReader dr = null;              try             {                 active_connection.Open();                 cmd.Connection = active_connection;                 cmd.CommandType = CommandType.StoredProcedure;                 cmd.CommandText = 'dalsp_Select_Organization_Files';                  SqlParameter param;                  param = cmd.Parameters.Add('@p_organization_guid', SqlDbType.UniqueIdentifier);                 param.Value = new Guid(organization_guid);                  param = cmd.Parameters.Add('@p_file_type', SqlDbType.NVarChar, 50);                 param.Value = file_type;                  dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);                  if (dr.HasRows)                                     {                                         while (dr.Read())                     {                         File file = new File();                         file.OrganizationGuid = dr['OrganizationGuid'].ToString();                         file.FileGuid = dr['FileGuid'].ToString();                         file.FileLocation = dr['FileLocation'].ToString();                         file.FileName = dr['FileName'].ToString();                         file.FileType = (FileTypeEnum)Enum.Parse(typeof(FileTypeEnum), dr['FileType'].ToString());                         file.FileExtension = dr['FileExtension'].ToString();                         file.FileDescription = dr['FileDescription'].ToString();                         file.ThumbnailPath = dr['ThumbnailPath'].ToString();                         files.Add(file);                     }                        }                 dr.Close();                 dr = null;                  active_connection.Close();                 cmd = null;              }             catch (Exception)             {                 throw;             }             finally             {                 if (active_connection.State != ConnectionState.Closed)                 {                     active_connection.Close();                     active_connection.Dispose();                 }             }              return files; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:16:42+00:00Added an answer on May 10, 2026 at 8:16 pm

    If you are saying your files collection has 4 items, but the 4 item contains no value, what do you mean by that? Is it null, does the object have no data, or does it throw an index out of range exception?

    Are you doing a files[4] or something like the following?

    for(int x = 1; x < files.length; x++) {      files[x] } 

    That won’t work. Remember 0 based indexing in C#.

    As a side note, you could do away with your try catch statments by doing something like:

    using (SqlConnection connection = new SqlConnection(conn_string)) {     connection.Open();     using (SqlCommand cmd = new SqlCommand('SELECT * FROM MyTable', connection))     {          using (SqlDataReader dr = cmd.ExecuteReader())          {              return result;          }     } } 

    The using statement will guarantee disposal (and therefore the closing) of the reader and connection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 70k
  • Answers 70k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer With the first variant you reallocate the vector's buffer on… May 11, 2026 at 12:57 pm
  • added an answer Consider using symbolic links. I have a ~/work/ directory where… May 11, 2026 at 12:57 pm
  • added an answer Did you use tiny_impdef.exe to create a .def file for… May 11, 2026 at 12:57 pm

Related Questions

When running the following Java code, I get very accurate and consistent results in
When I am running the following statement: @filtered = map {s/&nbsp;//g} @outdata; it is
I get the following error when running my Visual Studio 2008 ASP.NET project (start
I'm running the following query in Hypersonic DB (HSQLDB): SELECT (CASE foo WHEN 'a'
I have made use of the following JPA implementations: Hibernate, Toplink, OpenJPA Each of
I'm using the following to grab some updated HTML and insert it into a
I am using the ReportViewer control from Visual Studio 2008 in Local Mode with
I have a .net web-service hosted in IIS 6.0 that periodically fails with an

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.