如何选择和计算excel中的全部0并将其显示为标签? [英] How to select and count all 0 in excel and show it to label?

查看:116
本文介绍了如何选择和计算excel中的全部0并将其显示为标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在标签中显示我的所有零点数我有这样的连接



How can i show all the count of my zero in label i have a connection like this

public void countMinor()
        {
            var ExcelPath2 = Application.StartupPath + "\\DB\\" + ConfigurationManager.AppSettings["ExcelDBPrize"];
            DataSet ds = new DataSet();
            OleDbConnection cn = null;
            OleDbDataAdapter cmd2 = null;
            cn = new OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;data source= " + ExcelPath2 + ";Extended Properties='Excel 12.0 XML;HDR=Yes;IMEX=1;'; ");
            cn.Open();
            cmd2 = new OleDbDataAdapter("SELECT COUNT(Status) AS STAT FROM [Sheet1$] WHERE Status = 0", cn);
            cmd2.Fill(ds);

            //lblMinor.Text = cmd2.ToString();
            cn.Close();
            //lblprizeno.Text = ds.Tables[0].Rows[randomprize][0].ToString();
        }



i会以加载形式使用它,但计数不会出现。



我尝试了什么:



i试图搜索这个,但我找不到我的确切答案


i gonna use this in load form but the count doesn't appear.

What I have tried:

i tried to search this but i can't find my exact answer

推荐答案

WHERE Status = 0,cn);
cmd2.Fill(ds);

//lblMinor.Text = cmd2.ToString();
cn.Close();
//lblprizeno.Text = ds.Tables [0] .Rows [randomprize] [0] .ToString();
}
WHERE Status = 0", cn); cmd2.Fill(ds); //lblMinor.Text = cmd2.ToString(); cn.Close(); //lblprizeno.Text = ds.Tables[0].Rows[randomprize][0].ToString(); }



i会以加载形式使用它,但计数不会出现。



我尝试过: < br $>


i试图搜索这个,但我找不到我的确切答案


i gonna use this in load form but the count doesn't appear.

What I have tried:

i tried to search this but i can't find my exact answer


这篇关于如何选择和计算excel中的全部0并将其显示为标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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