I have this code that gets the value from a SQL Query and place the value in a textbox. I want to put it to another class, and access it from the main class. But my problem is, The class wont recognize the button(txtbox_ticketnum) as it is from the main class. help!
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
using (SqlCommand com_retrieve = new SqlCommand("usp_SelectTop1Ticket", con))
{
com_retrieve.CommandType = CommandType.StoredProcedure;
con.Open();
try
{
txtbox_ticketnum.Text = com_retrieve.ExecuteScalar().ToString();
MessageBox.Show("Ticket Has been saved. Your Ticket Number: " + com_retrieve.ExecuteScalar().ToString(), "Ticket Filed");
}
catch (SqlException)
{
MessageBox.Show("The database has encountered an error");
}
catch (Exception)
{
MessageBox.Show("The server has encountered an error");
}
}
}