tags:

views:

103

answers:

1

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.

+12  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();
}
Mehrdad Afshari
Great that's the answer !
programmernovice

related questions