当我执行此代码时错误显示“未找到栏目资金“这段代码中的错误是什么?

问题描述:

con = new SqlConnection(cs);
           con.Open();
           cmd = con.CreateCommand();
           cmd = new SqlCommand("select distinct RTRIM(FundLeft) from Invoice ", con);
           rdr = cmd.ExecuteReader();


           while (rdr.Read())
           {

               DataRow[] dr = dt.Select("FundLeft = MIN(FundLeft)");
               txtfundleft.Text = dr[0][1].ToString();
           }
           con.Close();

错误信息非常明确:Column Fundleft is找不到

所以检查你的表格:你的发票表中是否有一栏Fundleft?我猜不是,而且你的意思完全不同。



当我们在这里时,那段代码就是......呃......很奇怪。

为什么使用Reader并忽略它返回的值?
The error message is pretty explicit: "Column Fundleft is not found"
So check your tables: is there a column "Fundleft" in your "Invoices" table? I'm guessing not, and that you meant a different table altogether.

And while we are here, that code is...um...rather odd.
Why are you using a Reader and ignoring the values it returns?