2
Well, I have a program that needs me to write using Abels, however these only work, and actually write when they are clicked, I would like someone to explain to me how I should proceed to be able to write as soon as the form is loaded:
EDIT: Basically as I said I’m trying to write data on a label that I took from a BD however this is only written when I click on the Abels, I would like it to be written as soon as the form and about is loaded, it is the code
SqlConnection conn = new SqlConnection(@"Data Source=.\wintouch;Initial Catalog=bbl;User ID=sa;Password=Pa$$w0rd");
conn.Open();
string info = ""; // open connection and creat the string that contains info
//-----------------------------------------------------------//
Timer timer1 = new Timer();
timer1.Tick += new EventHandler(label4_load);
timer1.Interval = 55;
timer1.Enabled = true;
string varsql = "SELECT sum(merc1)/2 as total FROM wgcdoccab where tipodoc ='FSS' and serie='1' and contribuinte='999999990' and datadoc = CONVERT(varchar(10),(dateadd(dd, -1, getdate())),120)"; //division query
SqlCommand cmd = new SqlCommand(varsql, conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
info = dr["total"].ToString().TrimEnd() + "," + "\r"; // search the database?
}
label4.Text = info; //display information on hte label
label4.Text = string.Format("new_text {0}", DateTime.Now.ToLongTimeString());
conn.Close();
timer1.Stop();
}`
Try to give more details about your question, post a code and/or image that can help in solving the problem.
– Ricardo