You can use the ADO.NET
DataReader
to retrieve a read-only, forward-only stream of data from a database. Results are returned as the query executes, and are stored in the network buffer on the client until you request them using the Read method of the
SqlDataReader
.
SqlConnection con = new SqlConnection();
con.ConnectionString = "Write your Connection String values";
con.Open();
SqlCommand cmd = new SqlCommand("Your query using Where Clause",con);
SqlDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
var value = dr[index]
}
for more Details take a look at this
Link-MSDN-[Retrieving Data Using the DataReader][
^]