本文介绍了FormatException未处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  private   void  BindGridInventory()
{
MySqlConnection con = new MySqlConnection( Server =本地主机; UID =根;数据库= db_cignal);
MySqlDataAdapter sda = new MySqlDataAdapter( select *来自库存,con);
MySqlCommandBuilder builder = new MySqlCommandBuilder(sda);
DataSet dt = new DataSet();
sda.Fill(dt); /// 这是我得到错误formatexception

if (dt.Tables.Count > 0
{
dataGridView1.DataSource = dt.Tables [ 0 ];
}
}
解决方案

private void BindGridInventory()
{
  MySqlConnection con = new MySqlConnection("Server=localhost;UID=root;Database=db_cignal");
  MySqlDataAdapter sda = new MySqlDataAdapter("select * from inventory", con);
  MySqlCommandBuilder builder = new MySqlCommandBuilder(sda);
  DataSet dt = new DataSet();
  sda.Fill(dt);///this is where i get the error formatexception

  if (dt.Tables.Count > 0)
  {
    dataGridView1.DataSource = dt.Tables[0];
  }
}
解决方案


这篇关于FormatException未处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 01:49