3

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.

1 Answer 1

14
using (var conn = new OleDbConnection(...))
using (var cmd = new OleDBCommand("select ...", conn)) {
   conn.Open();
   object result = cmd.ExecuteScalar(); // cast to appropriate type
   conn.Close();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.