没人回答...
下面的代码本人觉得比较傻也不知道能不能满足需求,有没有比较好的呀
private void GetData()
{
string strConn = "Data Source=.;Initial Catalog=dbXXX;User ID=sa;pwd=123456";
SqlConnection con = new SqlConnection(strConn);
SqlDataAdapter da = new SqlDataAdapter("select * from tableX", con);
DataSet ds = new DataSet();
da.Fill(ds);
int count = ds.Tables[0].Rows.Count;
progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
progressBar1.BackColor = Color.Green;
for (int i = 0; i < count; i++) //为了能看出效果
用for循环来减低速度
{
for (int j = 0; j < 1000; j++)
{
if (Convert.ToInt32(ds.Tables[0].Rows[i]["***"].ToString()) > 20)
cc++;
}
progressBar1.Value = ((i + 1) * 100 / count);
}
dataGridView1.DataSource = ds.Tables[0];
}