Reputation: 3941
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.
Upvotes: 3
Views: 966
Reputation: 421998
using (var conn = new OleDbConnection(...))
using (var cmd = new OleDBCommand("select ...", conn)) {
conn.Open();
object result = cmd.ExecuteScalar(); // cast to appropriate type
conn.Close();
}
Upvotes: 14