The ConnectionString property has not been initialized

Posts   
 
    
kirkov avatar
kirkov
User
Posts: 9
Joined: 09-May-2007
# Posted on: 09-May-2007 21:52:35   

Hi,

I have generated the code, build it, and setup the connectionstring in the app.config,

When i use the generated code i get this exception:

System.InvalidOperationException was unhandled by user code Message="The ConnectionString property has not been initialized." Source="System.Data" StackTrace: at System.Data.SqlClient.SqlConnection.PermissionDemand() at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteSingleRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityFields fieldsToFill) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformFetchEntityAction(IEntity entityToFetch, ITransaction containingTransaction, IPredicateExpression selectFilter, IPrefetchPath prefetchPathToUse, Context contextToUse) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.FetchExisting(IEntity entityToFetch, ITransaction containingTransaction, IPrefetchPath prefetchPathToUse, Context contextToUse) at bll.EntityClasses.ContentEntity.Fetch(Int32 pageId, IPrefetchPath prefetchPathToUse, Context contextToUse) in C:\Documents and Settings\Administrator\Dokumenter\LLBLGen Pro Projects\EntityClasses\ContentEntity.cs:line 567 at bll.EntityClasses.ContentEntity.InitClassFetch(Int32 pageId, IValidator validator, IPrefetchPath prefetchPathToUse) in C:\Documents and Settings\Administrator\Dokumenter\LLBLGen Pro Projects\EntityClasses\ContentEntity.cs:line 498 at bll.EntityClasses.ContentEntity..ctor(Int32 pageId) in C:\Documents and Settings\Administrator\Dokumenter\LLBLGen Pro Projects\EntityClasses\ContentEntity.cs:line 79 at Admin_Cms.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\Administrator\Dokumenter\VS2005\Mirror\Admin\CmsManage.aspx.cs:line 26 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I've checked the connectionString properties all over, i'm really lost?

Anyone had problems similar to this?

Thanks in advance.

Mark.

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 09-May-2007 22:21:34   

Web apps use web.config, not app.config

kirkov avatar
kirkov
User
Posts: 9
Joined: 09-May-2007
# Posted on: 09-May-2007 23:15:22   

JimHugh wrote:

Web apps use web.config, not app.config

Hi

Thanks for your reply.

I have attached a picture of the solution.

So the bll project (Generated code), is not a web app, is just a c# project the is being referenced to the web app "Mirror".

So the bll project can not have a web.config.

In the app.config, i tried both using the appSetings and the ConnectionStrings tags, but with no succes.

Thanks.

Attachments
Filename File size Added on Approval
llblgen_solution.png 16,962 09-May-2007 23:15.58 Approved
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 10-May-2007 01:17:01   

hiya,

just a guess, but (if the issue is that you don't really know what the dbConnString is)

why don't you try and View --> serverexplorer , and add the connection to the database that you want.Then, you can see what the dbConnString is via the properties.

If thaat isn't your issue, then try and genrate another project, based on the same database, see if that lets you see the dbConnString.

cheers,

yogi

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 10-May-2007 01:36:50   

kirkov, The runtime librearies consult the .config file of your output project. I your output project is a Console Application or Windows Application then you need to include a **app.config **in your Project (console or windows) root. If your output app is a Web Site (this is your case I guess) you need to incluide a **web.config **at the root of your site. It both of cases the .config file should have <appsetings/> section that you see at app.config of your bll project, that is added just for reference and contains the MainConnectionString key.

For more info review LLBLGenPro Help - Connection String.

David Elizondo | LLBLGen Support Team
kirkov avatar
kirkov
User
Posts: 9
Joined: 09-May-2007
# Posted on: 10-May-2007 12:21:00   

daelmo wrote:

kirkov, The runtime librearies consult the .config file of your output project. I your output project is a Console Application or Windows Application then you need to include a **app.config **in your Project (console or windows) root. If your output app is a Web Site (this is your case I guess) you need to incluide a **web.config **at the root of your site. It both of cases the .config file should have <appsetings/> section that you see at app.config of your bll project, that is added just for reference and contains the MainConnectionString key.

For more info review LLBLGenPro Help - Connection String.

Hi,

Yes, that works! It had to be in the <AppSettings> tag, in the web.config.

I really appreciate your help and very fast answers. simple_smile