Datagridview问题.填充和更新 [英] Datagridview problem. fill & update

查看:109
本文介绍了Datagridview问题.填充和更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.我有从该表中的销售"表中获取数据的表格是下一个列

Hello everybody. I have form which getting data from table ''Selling'' in this table is next columns

ID - int (have primary key)
BarCode - varchar(100)
ArtNumber - varchar(100)
ProductName - varchar(100)
Price - money
SelfPrice - money
PriceWithOutAWD - money
Comment - nvarchar(50)
DateTime - datetime
Quantity - nvarchar(50)


DataGridView数据源正在SellingBindingSource1.在这个中是带有按钮的toolStripMenu这个按钮


DataGridView DataSource is sellingBindingSource1. In this for is toolStripMenu with button this button

private void TsmRefresh_Click(object sender, EventArgs e)
        {
            sqlDataAdapter1.Fill(dataSet11);
        }


当我按下此按钮时,它不会刷新它会复制相同的数据
next按钮收到此错误.无法将参数值从String转换为Int32.这是按钮:


when i press this button it does not refresh it dublicates same data
next button gets this error Failed to convert parameter value from a String to a Int32. this is button:

private void TsmUpdate_Click(object sender, EventArgs e)
       {
           sqlDataAdapter1.Update(dataSet11);
       }


所以我的datagridview有问题.有人知道哪里出问题了吗?
加载此表单时,此代码可以正常工作:


so my datagridview have problems. Does anybody knows where is problem?
When this form is loading this code works fine :

private void TradeLog_Load(object sender, EventArgs e)
  {
      sqlDataAdapter1.Fill(dataSet11);
  }


谢谢.

推荐答案

不幸的是,DataAdapter从未如此简单.

我首先尝试为DataAdapter创建TableMappings.

根据我的经验,如果不先设置此项,它通常无法正常工作.
unfortunately, DataAdapters are never that easy.

I would first try creating the TableMappings for the DataAdapter.

Without setting this first, it often does not work correctly, in my experience.


这篇关于Datagridview问题.填充和更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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