简体   繁体   English

datagridview将不会更新

[英]datagridview won't update

I have this datagridview: 我有这个datagridview:

我的数据网格

using this procedure: 使用此过程:

 alter proc [dbo].[verfornecex1] (@FILA INT )   as
 select idfornec,nome,conta,ativo from tbfornec
 where Nome is not null and IdFornec = @fila
 order by Nome 

I have written this code: 我写了这段代码:

SqlConnection conec2 = Tconex.Minifim();
DataSet grava = new DataSet();
       SqlDataAdapter dap1 = new SqlDataAdapter();
       SqlCommandBuilder constru9 = new SqlCommandBuilder(dap1);
       SqlCommand llena11 = new SqlCommand("verfornecex1", conec2);
       llena11.CommandType = CommandType.StoredProcedure;
       SqlParameter tpd = new SqlParameter("@fila", SqlDbType.Int);
       tpd.Value = vlz;
       llena11.Parameters.Add(tpd);
       dap1.SelectCommand = llena11;
       dap1.Fill(grava, "fabricante");
       DataRow dr3 = grava.Tables["fabricante"].NewRow();
       dr3["ativo"] = 1;
       dap1.Update(grava, "fabricante");

But something is wrong there. 但是那里有些问题。 I use DataSet because DataTable doesn't make update. 我使用DataSet是因为DataTable不会进行更新。

Do you have a connection to the database?, probably that is conec2, but just check it 您是否有与数据库的连接?可能是conec2,但只需检查一下即可

I think you're missing a DataTable function? 我认为您缺少DataTable函数?

SqlCommand llena11 = new SqlCommand("verfornecex",conec2);
SqlDataAdapter dap1 = new SqlDataAdapter();
dap1.SelectCommand = llena11;
DataTable grava = new DataTable();
dap1.Fill(grava, "fabricante");
dataGridView1.DataSource = grava;
dapt1.Update(grava, "fabricante");

Hope this helps a little... 希望这有所帮助...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM