I\'m trying to return a single row from a database:
using (connection = new SqlConnection(ConfigurationManager.AppSettings[\"connection\"])) { using (command
You can use an if statement if your query only returns one value
if
[...] string x = string.Empty; if(reader.Read()) { // make sure the value is not DBNull if(DBNull.Value != reader["col_1"]) { x = reader.GetString(0); } } [...]