Buka MSDN untuk mempelajarinya http://msdn.microsoft.com/en-us/bb188199 .
Berikut adalah contoh tentang cara menghubungkan ke database.
private static void ReadOrderData(string connectionString)
{
string queryString =
"SELECT OrderID, CustomerID FROM dbo.Orders;";
using (SqlConnection connection =
new SqlConnection(connectionString))
{
SqlCommand command =
new SqlCommand(queryString, connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
// Call Read before accessing data.
while (reader.Read())
{
Console.WriteLine(String.Format("{0}, {1}",
reader[0], reader[1]));
}
// Call Close when done reading.
reader.Close();
}
}
Ada banyak sumber di luar sana, coba cari dulu sebelum memposting pertanyaan.