Save dataset C #

2

I'm looking for multiple database tables for Dataset through Stored Procedure on MySQL using MySQL Workbrenck, but at the time of saving only the first table is saved, my code:

Stored Procedure:

CREATE DEFINER='root'@'localhost' PROCEDURE 'Tabelas_Materia_Prima'()
BEGIN

    SELECT * FROM materia_prima_ar order by 'DATA';
    SELECT * FROM materia_prima_amido order by 'DATA';
    SELECT * FROM materia_prima_art order by 'DATA';
    SELECT * FROM materia_prima_umidade order by 'DATA';
    SELECT * FROM materia_prima_pol order by 'DATA';
    SELECT * FROM materia_prima_infeccao order by 'DATA';
    SELECT * FROM materia_prima_imp_veg order by 'DATA';
    SELECT * FROM materia_prima_imp_min order by 'DATA';
    SELECT * FROM materia_prima_fosfato order by 'DATA';
    SELECT * FROM materia_prima_fibra order by 'DATA';
    SELECT * FROM materia_prima_dextrana order by 'DATA';    

END

Method to save Dataset again:

public void Salvar_Procedure(DataSet Dados, string Nome_Procedure)
{
     MySqlConnection Conexao = new MySqlConnection(StringConexao);

     //OdbcConnection Conexao = new OdbcConnection("DSN=YasFashion_Sacoleiro_DB");

     MySqlCommand Comando = new MySqlCommand();
     Comando.Connection = Conexao;
     Comando.CommandType = CommandType.StoredProcedure;
     Comando.CommandText = Nome_Procedure;
     MySqlDataAdapter Meu_Adaptador = new MySqlDataAdapter(Comando);

     //OdbcDataAdapter Meu_Adaptador = new OdbcDataAdapter("SELECT * FROM " + Nome_Tabela, Conexao);

     try
     {
          Conexao.Open();

          MySqlCommandBuilder Comando01 = new MySqlCommandBuilder(Meu_Adaptador);

         //OdbcCommandBuilder Comando = new OdbcCommandBuilder(Meu_Adaptador);

         Meu_Adaptador.Update(Dados);

         Conexao.Close();
      }
      catch (Exception ex)
      {
           MessageBox.Show("Erro de salvamento: \n" + ex);
      }
}
    
asked by anonymous 23.11.2016 / 01:06

1 answer

0

Does your Proc run when called directly from the DBMS? If not, take a look if it is not getting lost with the column names of the different types of tables.

You can compose the select by explicit fields with the same name for each query. It looks like the object you save is the first select.

You can use all of them in a View using UNION from sql to put all the data as if it were a single table.

    
23.11.2016 / 17:59