Look at your code: You create a connection:
SqlConnection con = Connection.GetConnection();
You open it:
con.Open();
And you then ignore it and create another:
SqlCommand cmd = new SqlCommand(sqlquery, Connection.GetConnection());
Use the one you just opened, and it'll work:
SqlCommand cmd = new SqlCommand(sqlquery, con);
I'd strongly suggest that you look at
using
blocks though - they ensure teh connection is correctly closed and disposed when you are finished with it:
using (SqlConnection con = Connection.GetConnection())
{
con.Open();
using (SqlCommand cmd = new SqlCommand(sqlquery, con))
{
using (SqlDataReader dr = cmd.ExecuteReader())
{
if (dr.Read())
{
string value = dr[0].ToString();
if (string.IsNullOrWhitespace(value))
{
textbox.Text = "111";
}
else
{
textbox.Text = value;
}
}
}
}