I'm not an expert and it's been more than a year since I've used C# (needed it for school) but if I remember correctly it goes something like this using SQL server:
using System.Data.SqlClient; //Namespace
SqlConnection conn = new SqlConnection(
"server=myservername;database=mydatabasename;uid=m yusername;pwd=mypassword"); /* defining a SQL connection named 'conn' with the correct servername, databasename, userid and password. The thing between brackets is the connection string, there is a whole website somewhere about nothing but the connectionstring. */
conn.Open(); // open the connection
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select x from x where x";//Using your SQL command
cmd.Connection = conn;
string Result = (string)cmd.ExecuteScalar(); //Put the result in a string named Result
Console.Writeline(Result); //Writes it in the console
conn.Close(); // close the connection
For multiple results you can use SqlDataReader.
The framework database programming classes are referred to as ADO.NET . Look ok the internet for ADO.NET tutorials. Programming is all about managing and manipulating data, so if it's your ambition to develop professional web applications using C# and .NET for, you need to learn this stuff.
If you don't know how to use SQL commands, you should learn that too.
SQL Tutorial - Learn SQL is the website I learned it from.