I have connected to my database using Data Connection Server Explorer and the same is added to my web.config as well. Now can someone tell me how to query it?
1 Answer
Sure, you could do this:
using (SqlConnection c = new SqlConnection(ConfigurationManager.ConnectionStrings["key_of_element"]))
{
c.Open();
using (SqlCommand cmd = new SqlCommand("SELECT * FROM Table"))
{
var reader = cmd.ExecuteReader();
while (reader.Read())
{
// do something with the data
}
}
}