/ Published in: C#
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
private void bindSomething() { string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString_From_WebConfig"].ConnectionString; string selectSQL = "Select * from tablename"; try { conn.Open(); SqlDataReader reader = getStuff.ExecuteReader(); while (reader.Read() == true) { someLabel.Text = Convert.ToString(reader["column1"]); someLabel2.Text = Convert.ToString(reader["column2"]); } reader.Close(); } catch { Response.Write("Error retrieving data"); } finally { conn.Close(); } }