I’m using a method in the EnterpriseLibrary.Data.Database namespace called
public virtual object ExecuteScalar(DbCommand command)
I’m wanting to use this method to execute a scalar-valued function. However the I’m not sure how to even create the DbCommand.
Could someone please tell me how to create it because it won’t let me instantiate it.
Thanks!
They’re using the factory pattern, (one of the major benefits from using the enterprise library data access application block). The database needs to be correctly configured in app.config (or web.config). You can see an example of that here.
Here is an example of how you create a command:
(Remember to dispose.)