Skip to content

Where a command returns multiple tables, and the last table has no rows, it is not included in the DataAdapter #524

@badbod99

Description

@badbod99

I'm using MySqlDataAdapter.Fill to fill a DataSet like this:

public static DataSet RetrieveDataSet(string connectionString, string storedProcedure, params MySqlParameter[] parameters)
        {
            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                conn.Open();

                using (MySqlCommand comm = conn.CreateCommand())
                {
                    comm.CommandText = storedProcedure;
                    comm.CommandType = CommandType.StoredProcedure;
                    if (parameters != null && parameters.Length > 0)
                    {
                        comm.Parameters.AddRange(parameters);
                    }

                    using (MySqlDataAdapter adapter = new MySqlDataAdapter(comm))
                    {
                        DataSet data = new DataSet();
                        adapter.Fill(data);
                        return data;
                    }
                }
            }
        }

My stored procedure returns 4 result sets. In the case that result set 4 (the last one) is empty, the data.Tables.Count equals 3. In the case that result set 4 has rows, data.Tables.Count equals 4. In the case that result set 2 has no rows, data.Tables.Count equals 4 still.

So it seems like if the last result set is blank, it is not being included as a table in the dataset. My guess is that this is a for loop error, but I couldn't identify it from the code of MySqlDataAdapter.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions