Minor mistake on KB article Q318607

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Just want to report an error on the KB article Q318607, which is last
reviewed at September 15, 2005.
How to populate the datagrid on background thread with data
binding by using Visual C#.

In the example, QueryDataBase is called within the new thread, and
the function call MyForm.label1.Text violates the cross-thread principle.
It doesn't blow up in .NET 2003 but it gives InvalidOperation in .NET 2005.


static void QueryDataBase()
{
MyDataSet = new DataSet();
MyConnection.Open();
MyDataAdapter = new SqlDataAdapter(MyQueryString, MyConnection);
MyForm.label1.Text = "Filling the DataSet";
MyDataAdapter.Fill(MyDataSet, "MyTable");
MyConnection.Close();
MyForm.label1.Text = "DataSet Filled";
MyForm.BeginInvoke(CallDataBindToDataGrid);
}


Regards
Stan.
 
you should submit this to KB support instead of posting it here. Chances are
it won't make it up the right path from here

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
¤ Just want to report an error on the KB article Q318607, which is last
¤ reviewed at September 15, 2005.
¤ How to populate the datagrid on background thread with data
¤ binding by using Visual C#.
¤
¤ In the example, QueryDataBase is called within the new thread, and
¤ the function call MyForm.label1.Text violates the cross-thread principle.
¤ It doesn't blow up in .NET 2003 but it gives InvalidOperation in .NET 2005.
¤
¤
¤ static void QueryDataBase()
¤ {
¤ MyDataSet = new DataSet();
¤ MyConnection.Open();
¤ MyDataAdapter = new SqlDataAdapter(MyQueryString, MyConnection);
¤ MyForm.label1.Text = "Filling the DataSet";
¤ MyDataAdapter.Fill(MyDataSet, "MyTable");
¤ MyConnection.Close();
¤ MyForm.label1.Text = "DataSet Filled";
¤ MyForm.BeginInvoke(CallDataBindToDataGrid);
¤ }
¤
¤

Sounds like it should be reported as a bug. The KB article only applies to 2002 and 2003 (although
it should work under 2005 after this version is released).


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Back
Top