The ConnectionString property has not been initialized.

Posts   
 
    
BB
User
Posts: 45
Joined: 10-Dec-2008
# Posted on: 24-Feb-2009 16:00:29   

The web app uses several databases so I'm using adapter with an adapter factory. The adapter is created in the Page_Load.

The control is the Telerik RadGrid. The issue is with paging.

The Grid loads and renders the first page without any problems. However when I click on the pager contorl to ask for a new page I get a dialog box with this message:

"The ConnectionString property has not been initialized."

So I've been trying to solve this for a few days and I feel like I must be missing something really simple.

This should be easy... right? If not then how do I do it?

Barry

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 24-Feb-2009 21:31:06   

How are you supplying the ConnectionString to the DataAccessAdapter - via the app.config file, or passed as a parameter to the constructor...?

Matt

BB
User
Posts: 45
Joined: 10-Dec-2008
# Posted on: 24-Feb-2009 22:08:15   

The adapter factory creates the adapter including setting the connection string.

protected void Page_Load(object sender, EventArgs e)
  {
    if (!IsPostBack) { SetDBConnection(); }
  }

private void SetDBConnection()
  {
    try
    {
      IDataAccessAdapter dataAdapter = MDProOnlineUtility.GetMDPSystemDataAdapter();
      LLBLEventLog.AdapterToUse = dataAdapter;
    }
    catch (Exception)
    {

    }
  }

The connection string is set correctly in the adapter and does successfully render page 1. However on the post back to get subsequent pages it fails.

Barry

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 24-Feb-2009 22:19:48   

and can you tell (by debugging or logging) if the call to SetDBConnection(); is happening on each post back...?

BB
User
Posts: 45
Joined: 10-Dec-2008
# Posted on: 24-Feb-2009 22:43:17   

Corrected: Yes its getting called on each Post Back.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 24-Feb-2009 22:53:59   

if you make page_load look like this does it work ?

protected void Page_Load(object sender, EventArgs e) { SetDBConnection(); }

BB
User
Posts: 45
Joined: 10-Dec-2008
# Posted on: 25-Feb-2009 16:16:06   

We tried that a few days ago, it didn't change the symptoms.

I looking at using the Init event. I cant tell if it works yet because it is causing another problem.

(Not a LLBLGen Problem, but doesn't run just yet)

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 25-Feb-2009 16:23:47   

Would you like to share the info of that other problem, or it's something you can handle. Anyway, I'll close this thread temporarily till you post a reply.

BB
User
Posts: 45
Joined: 10-Dec-2008
# Posted on: 25-Feb-2009 17:36:02   

OK, For some reason, I guess its just that way...

Telerik has a Page_Load and an Init event. The Init event fires before the Page_Load. We have been setting the Adapter in the Page_Load event for a few months on many Web Forms and everything seemed to work fine. However I did not realize that none of our Web Forms used paging. I also did not know that one of my developers tried to get paging to work but did not succeed.

Apparently... for the 1st page the check for connection string is AFTER the Page_Load event. However after the first page the check for a valid connection string is BEFORE the Page_Load event.

I am now setting my adapter in the INIT event and it appears to be working correctly.

Barry