Database name not found in config fileDatabase name not found in config file
Old forum URL: forums.lhotka.net/forums/t/6720.aspx
Pete posted on Wednesday, April 01, 2009
Hi All,
I keep getting the error:
DataPortal.Fetch failed (Database name not found in config file (AdventureWorksLT))
My Dataportal_Fetch code looks like this :
Private Overloads Sub DataPortal_Fetch(ByVal criteria As SingleCriteria(Of Customer, Integer))
Using ctx = ContextManager(Of DalLinq.AdventureWorksDataContext).GetManager(DalLinq.Database.AdventureWorksLTConnectionString)
Dim data = (From p In ctx.DataContext.Customers Where p.CustomerID = criteria.Value Select p).Single
LoadProperty(Of Integer)(CustomerIdProperty, data.CustomerID)
LoadProperty(Of String)(CompanyNameProperty, data.CompanyName)
End Using
End Sub
My Database.vb file looks like this:
Public Class Database
Public Const AdventureWorksLTConnectionString As String = "AdventureWorksLT"
End Class
And my App.Config file contains the following:
<connectionStrings>
<add name="AdventureWorksLT" connectionString="Data Source=(local);Initial Catalog=AdventureWorksLT;User Id=AdvWorks;Password=UserPW;"
providerName="System.Data.SqlClient" />
</connectionStrings>
What am I missing?
Thanks!
ajj3085 replied on Wednesday, April 01, 2009
Try using the GetManager overload which takes two parameters. I don't know off the top of my head which value you'll need to pass, but the second parameter should make it clear what you're intending to do.
Copyright (c) Marimer LLC