Weird error when I try to extend Data.Sql.SqlDatabase

Topics: Data Access Application Block
Nov 4, 2008 at 8:25 PM
Edited Nov 4, 2008 at 10:22 PM

I override DeriveParameters in the derived class b/c that is required.

But when I try to build I get the following compiler error: "'Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase' does not contain a constructor that takes '0' arguments."

This doesn't make sense to me.  I've tried different constructor variations in the derived classes in order to try to debug:

* create an excplicit no arg constructor in the derived class
* create no explicit constructors (let the implicit no arg constructor be used)
* create a constructor with 1 arg so the implicit no arg constructor is not created

None of these variations fix the compiler error so I guess that I am just having a hard time making sense of the error.  Any suggestions?

Nov 5, 2008 at 1:22 AM
You should define a constructor that takes a connection string and a DbProviderFactory. 

public class MyDatabase : Database
public MyDatabase(string connectionString, DbProviderFactory factory)
base(connectionString, factory)
    protected override void DeriveParameters(System.Data.Common.DbCommand discoveryCommand)

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.