FormatException未处理 [英] FormatException was unhandled
本文介绍了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 ];
}
}
解决方案
我们无法断言:你需要先看看你的数据库以及库存表包含的值。有些东西是不同的并导致问题。
如果您有大量数据,如果您尝试检索信息的页面,它可能会有所帮助,直到您找到它所在的页面为止 - 然后使用相同的方法将其缩小到那里的特定行。
SELECT * FROM
( SELECT ColumnA,ColumnB,ROW_NUMBER() OVER ( ORDER BY ColumnA DESC ) AS R FROM inventory) AS A
WHERE A.R> = 0 AND a.R&α25
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];
}
}
解决方案
We can't tell from that: you need to start by looking at your database and what values the inventory table contains. Something is there is "different" and is causing the problem.
If you have a lot of data, it may help if you try retrieving "pages" of information until you find which "page" it's in - then narrow it down to a particular row from there using the same method.
SELECT * FROM (SELECT ColumnA, ColumnB, ROW_NUMBER() OVER (ORDER BY ColumnA DESC) AS R FROM inventory) AS A WHERE A.R>=0 AND a.R<25
这篇关于FormatException未处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文