2. construct connection string... if you do not know how to do that use wizard... to do that select from main menu of VS: Data -> Add new data source -> Choose a datasource tylpe (database) -> click New connection and copy the connection string constructed by the wizard...
3. connect to a database and execute query:
using (SqlConnection connection = new SqlConnection(connectionString))
SqlCommand command = new SqlCommand(query, connection);
SqlDataReader sqlReader = command.ExecuteReader();
// check the result