Error: The DataSourceKey [] is not defined.


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yeah...I figured that was the case...glad you got it going! Smile
Larry Tucker
Larry Tucker
StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)
Group: StrataFrame Users
Posts: 69, Visits: 308
Trent,

Good call on the Global.asax file.  For whatever reason, probably operator error Whistling ,sending up a fresh version to the website solved it.  Commencing headbanging...

Larry

Larry Tucker
Larry Tucker
StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)
Group: StrataFrame Users
Posts: 69, Visits: 308
Okay.  Thanks for the clarification. 

I understand the DataLayer.DataSources.Add() is where the item is created in the collection.  I meant that I would have expected it to return some sort of failure warning / exception if it had not created the DataSourceItem.  It never occurred to me that a web app could run without the app_start firing Crazy

Moving from the self-contained world of VFP to this disconnected / remote environment is tough.  There are layers upon layers of things that can go wrong.  Sometimes it feels like visiting a foreign country where you miss things that are obvious to the local residents because you don't know the context of the culture / language.  Bet you never considered yourself a "tour guide".Wink

Again, your support is much appreciated.   I'm doing a lot of reading and troubleshooting before resorting to your guidance.

-- Larry

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Could you explain how you came up with this?  The DataSource collection isn't mentioned in the error message.  How did you go from "DataSourceKey [] is not defined" to "missing DataSource item"?

Well, a data source key is comes from the DataSourcesCollection.  The key means absolutely nothing if it doesn't exist in the data sources collection.  This is set in the Application_Start in the global.asax when  you add your data source item to the data source collection.

That's how I went there. Smile

Wouldn't the DataLayer.DataSources.Add() fail in the Global.asax file if the datasource was not added? 

That IS the data source collection.  DataSources is a colleciton of data source items.

Assuming it succeeded, are you saying check it again when my SchoolBO.FillAll() fires because something in the web hosting environment could have deleted it in the interim? 

Yup.  When the SchoolBO.FillAll() happens it uses its data source key to pull from the data source collection when the DAL is going to fetch the data.  By this time the data source item within the collection apparently is not there.  So the hosting environment could be doing something that is forcing the shared classes to be GC'ed or shut down and then recreated without going through the Application_Start.  Do you even know if the Application_Start is evern happening on the hosted site?  That is the first thing I would check.

Larry Tucker
Larry Tucker
StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)
Group: StrataFrame Users
Posts: 69, Visits: 308
The hosted environment doesn't have the DataSources collection populated when the BO is referencing it, thus it throws the error.

Could you explain how you came up with this?  The DataSource collection isn't mentioned in the error message.  How did you go from "DataSourceKey [] is not defined" to "missing DataSource item"?

You might write to a log file or something when the connection is created to ensure that the data source is being added.

Again, I need more information.  Wouldn't the DataLayer.DataSources.Add() fail in the Global.asax file if the datasource was not added?  Assuming it succeeded, are you saying check it again when my SchoolBO.FillAll() fires because something in the web hosting environment could have deleted it in the interim? 

Thanks,

Larry

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
The issue is actually straight forward in the sense of the error.  The hosted environment doesn't have the DataSources collection populated when the BO is referencing it, thus it throws the error.  You might write to a log file or something when the connection is created to ensure that the data source is being added.  The hosted environment may also be resetting the application pool, sessions, or something along those which is loosing instantiated objects.
Larry Tucker
Larry Tucker
StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)
Group: StrataFrame Users
Posts: 69, Visits: 308
I'm getting the error (below) when run on my production website.  The app runs fine on my development machine.  As a result, am stumped as to how to debug it.

The SaeWeb project is referencing my SaeBOL project for business objects.

On my dev machine, I can see that my Global.asax.vb is creating a DataSource correctly with "" key and correct connectionstring:

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
DataLayer.DataSources.Add(New SqlDataSourceItem("", _
"Data Source=tcp:sql2k513.discountasp.net;Initial Catalog=SQL2005_386891_sae; User ID=*****; Password=*****"))
End Sub

My SchoolBO has a "" as its DataSourceKey.

Much to my amazement, when run on my development machine this web page is actually connecting the the production SQL database at the web host.

Not sure what might be missing in the installed version on the website.  Any help much appreciated. 

-- Larry  (using VS2008 and .NET 3.5 build target)

Server Error in '/' Application.
--------------------------------------------------------------------------------

The DataSourceKey [] is not defined.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack
trace for more information about the error and where it originated in the code.

Exception Details: MicroFour.StrataFrame.Data.DataLayerException: The DataSourceKey [] is not defined.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin
and location of the exception can be identified using the exception stack trace below. 

Stack Trace:


[DataLayerException: The DataSourceKey [] is not defined.]
   MicroFour.StrataFrame.Data.DataLayer.Create(BusinessLayer BusinessObject, ISynchronizeInvoke SyncObject, Boolean CheckDesignTime) +271
   MicroFour.StrataFrame.Business.BusinessLayer.get__DataLayer() +79

[DataLayerException: An error occurred while creating a new DataLayer for the business object.]
   MicroFour.StrataFrame.Business.BusinessLayer.get__DataLayer() +149
   MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(String SelectStatement) +15
   SaeBOL.SchoolBO.FillAll() +13
   SaeWeb.SchoolForm.Page_Load(Object sender, EventArgs e) +46
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search