Click here to Skip to main content
15,895,606 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
hi,
i m using Enterprise Library 6.0 for data access, i m download it and installed, but when i used it for CRUD operation than it through exception like:

{"Database provider factory not set for the static DatabaseFactory. Set a provider factory invoking the DatabaseFactory.SetProviderFactory method or by specifying custom mappings by calling the DatabaseFactory.SetDatabases method."}
Posted
Updated 15-Jan-17 8:55am

1 solution

I was facing the same problem, below code worked for me.

Web.config:
Change dataConfiguration section as per below configuration:

<section name="dataConfiguration"
 type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
           Microsoft.Practices.EnterpriseLibrary.Data"/>


Also change the code where you are accessing the DatabaseFactory.CreateDatabase().
DatabaseProviderFactory factory = new DatabaseProviderFactory();
var db = factory.Create("ConnectionString");
var ds = new DataSet();
var cmd = db.GetStoredProcCommand("uspGetDetails");
db.AddInParameter(cmd, "@userName", DbType.String, "Developer");
ds = db .ExecuteDataSet(cmd);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900