In mojoPortal we don't like to talk directly to the database from UI code (nor have any references to it). UI code talks to business class objects which in turn call the data access code.
Of course in your own custom features you are free to do whatever you want. There is ample data access code in mojoPortal that can be studied for examples though the data layer for MS SQL uses stored procedures whereas most of the other data layers build up sql statements using StringBuilder.
Be careful about using DataReaders to make sure you close the connection its best to use using blocks like change your code like this:
string sql1 = "SELECT TOP 1 * FROM News WHERE NewsCatID = 6 ORDER BY NewsDate Desc";
using(SqlConnection con = new SqlConnection(connectionString1))
{
SqlCommand cmd = new SqlCommand(sql1, con)
con.Open();
using(SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
lbl_Description.Text = reader["Description"];
}
}
}
}
the using block makes sure to dispose the object and close the underlying connection, otherwise you could be leaking connections from the conneciton pool and this will hurt performance and can cause the app to hang if it exhausts the pool of available connections. If your sql returns only a single row its probably cleaner to use if instead of while
Hope that helps,
Joe