如何在数据库mysql中保存所有数据集表 [英] How to save all dataset tables in database mysql

查看:229
本文介绍了如何在数据库mysql中保存所有数据集表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用dataadapter将所有数据集的表保存在数据库中。当我试图保存这个时,只有第一张表被保存而其他表没有。



我尝试了什么:



我使用mysql workbrenck中的存储过程从数据库获取数据:



I can't save all dataset's tables in database using dataadapter. When I try to save this, only first table is saved the others not.

What I have tried:

I get data from database using stored procedure in mysql workbrenck:

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





所以,我这样做在表数据中修改,然后我尝试在datatable中保存表,但只保存第一个表。 :(。如何在数据库中保存所有数据表?





So, I do modification in tables data, then I try to save tables in datatable, but only first table is saved. :(. How can I save all datatable in database?

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);
            }
        }

推荐答案

从表中检索的所有数据是否存储在同一数据集中?

您如何存储您选择的数据?我看不到你在哪里存放它。



也许你应该使用像
这样的东西


数据集a = sql语句(SELECT * FROM materia_prima_ar order通过'DATA';)

数据集b = sql语句(SELECT * FROM materia_prima_amido order by'DATA';)

etc(这不是正确的代码,只是尝试让你知道我认为你应该怎么做呢)



所以你应该为每个select语句分配一个数据集,然后将每个datset保存回表格是在任何更改后选择的。
Are all the data retrieved from the tables stored in the same dataset?
How are you storing the data you select? I can't see where you are storing it.

Maybe you should be using something like

dataset a = sql statement (SELECT * FROM materia_prima_ar order by 'DATA';)
dataset b = sql statement (SELECT * FROM materia_prima_amido order by 'DATA';)
etc (this is not proper code, but just trying to give you an idea how I think you should try to do it)

So you should have a dataset allocated for each select statement, then save each datset back to the table it was selected from after any changes.


这篇关于如何在数据库mysql中保存所有数据集表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆