Q:

How to return single sql result in a string without using datatable (C#)?

I know how to fill a datatable with dAdapter.Fill(dTable) using System.Data.OleDb
But it's heavy if I just want to retrieve a single string value like "select name from table where idperson = 1"
Can't I bypass creating a DataTable ?
I want to create an equivalent of dlookup function in MS Access.

A:

using (var conn = new OleDbConnection(...))
using (var cmd = new OleDBCommand("select ...", conn)) {
   conn.Open();
   object result = cmd.ExecuteScalar(); // cast to appropriate type
   conn.Close();
}

