I\'m trying to return a single row from a database:
using (connection = new SqlConnection(ConfigurationManager.AppSettings[\"connection\"])) { using (command
Instead of:
using (reader = command.ExecuteReader()) { reader.Read(); return reader["col_1"]; }
You need to cast the reader["col_1"] to string, either reader["col_1"].ToString() or reader.GetString(0) like:
reader["col_1"]
reader["col_1"].ToString()
reader.GetString(0)
return reader.GetString(0);