You need an SqlConnection, SqlCommand, SqlDataReader (you can use SqlDataReader, but let's keep it simple)
Now in order to connect you have to write the following code
string connectionString = "server=.; uid=Your_SQL_Username; pwd=Your_SQL_Password; database=The_Name_Of_Your_Database";
SqlConnection conn = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("select * from tables", conn);
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
while(dr.Read())
{
MessageBox.Show(dr[0].ToString());
MessageBox.Show(dr[1].ToString());
}
conn.Close();