I have a datagridview and a label with text "Fetching data ...". some data is fetched from remote sql server database which probably takes some time. I want to show this "fetching data ..." label till the data is loaded.
my code on button click is:
label1.Visible = true;
String connection = "Data Source = 19xx.xx.xx; Initial Catalog =xxx; integrated security = false ; User ID=XXX; Password=XXX";
String query = "select * from sys.tables";
SqlConnection con = new SqlConnection(connection);
SqlDataAdapter ad = new SqlDataAdapter(query, con);
DataTable dt = new DataTable();
ad.Fill(dt);
dataGridView1.DataSource = dt;
label1.Visible = false;
i tried background worker but it gives cross thread error.