﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WebForms (How do I?)  » Error:  The DataSourceKey [] is not defined.</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Mon, 08 Jun 2026 22:44:37 GMT</lastBuildDate><ttl>20</ttl><item><title>Error:  The DataSourceKey [] is not defined.</title><link>http://forum.strataframe.net/FindPost15711.aspx</link><description>I'm getting&amp;nbsp;the error (below) when run on my production website.&amp;nbsp; The&amp;nbsp;app runs&amp;nbsp;fine on my development machine.&amp;nbsp; As a result, am stumped as to how to debug it.&lt;/P&gt;&lt;P&gt;The SaeWeb project is referencing my SaeBOL project for business objects.&lt;/P&gt;&lt;P&gt;On my dev machine, I can see that my Global.asax.vb is creating a DataSource correctly with "" key and correct connectionstring:&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;[codesnippet]Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)&lt;BR&gt;DataLayer.DataSources.Add(New SqlDataSourceItem("", _&lt;BR&gt;"Data Source=tcp:sql2k513.discountasp.net;Initial Catalog=SQL2005_386891_sae; User ID=*****; Password=*****"))&lt;BR&gt;End Sub[/codesnippet]&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/FONT&gt;&lt;P&gt;My SchoolBO has a "" as its DataSourceKey.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Not sure what might be missing in the installed version on the website.&amp;nbsp; Any help much appreciated.&amp;nbsp; &lt;/P&gt;&lt;P&gt;-- Larry&amp;nbsp; (using VS2008 and .NET 3.5 build target)&lt;/P&gt;&lt;P&gt;Server Error in '/' Application.&lt;BR&gt;--------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;The DataSourceKey [] is not defined. &lt;BR&gt;Description: An unhandled exception occurred during the execution of the current web request. Please review the stack &lt;BR&gt;trace for more information about the error and where it originated in the code. &lt;/P&gt;&lt;P&gt;Exception Details: MicroFour.StrataFrame.Data.DataLayerException: The DataSourceKey [] is not defined.&lt;/P&gt;&lt;P&gt;Source Error: &lt;/P&gt;&lt;P&gt;An unhandled exception was generated during the execution of the current web request. Information regarding the origin &lt;BR&gt;and location of the exception can be identified using the exception stack trace below.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Stack Trace: &lt;/P&gt;&lt;P&gt;&lt;BR&gt;[DataLayerException: The DataSourceKey [] is not defined.]&lt;BR&gt;&amp;nbsp;&amp;nbsp; MicroFour.StrataFrame.Data.DataLayer.Create(BusinessLayer BusinessObject, ISynchronizeInvoke SyncObject, Boolean CheckDesignTime) +271&lt;BR&gt;&amp;nbsp;&amp;nbsp; MicroFour.StrataFrame.Business.BusinessLayer.get__DataLayer() +79&lt;/P&gt;&lt;P&gt;[DataLayerException: An error occurred while creating a new DataLayer for the business object.]&lt;BR&gt;&amp;nbsp;&amp;nbsp; MicroFour.StrataFrame.Business.BusinessLayer.get__DataLayer() +149&lt;BR&gt;&amp;nbsp;&amp;nbsp; MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(String SelectStatement) +15&lt;BR&gt;&amp;nbsp;&amp;nbsp; SaeBOL.SchoolBO.FillAll() +13&lt;BR&gt;&amp;nbsp;&amp;nbsp; SaeWeb.SchoolForm.Page_Load(Object sender, EventArgs e) +46&lt;BR&gt;&amp;nbsp;&amp;nbsp; System.Web.UI.Control.OnLoad(EventArgs e) +99&lt;BR&gt;&amp;nbsp;&amp;nbsp; System.Web.UI.Control.LoadRecursive() +47&lt;BR&gt;&amp;nbsp;&amp;nbsp; System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436&lt;/P&gt;&lt;P&gt;&lt;BR&gt;--------------------------------------------------------------------------------&lt;BR&gt;Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433</description><pubDate>Thu, 17 Apr 2008 16:23:01 GMT</pubDate><dc:creator>Larry Tucker</dc:creator></item><item><title>RE: Error:  The DataSourceKey [] is not defined.</title><link>http://forum.strataframe.net/FindPost15747.aspx</link><description>Yeah...I figured that was the case...glad you got it going! :)</description><pubDate>Thu, 17 Apr 2008 16:23:01 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Error:  The DataSourceKey [] is not defined.</title><link>http://forum.strataframe.net/FindPost15743.aspx</link><description>Trent,&lt;P&gt;Good call on the Global.asax file.&amp;nbsp; For whatever reason, probably operator error&amp;nbsp;:Whistling: ,sending up a fresh version to the website solved it.&amp;nbsp; Commencing headbanging...&lt;/P&gt;&lt;P&gt;Larry</description><pubDate>Thu, 17 Apr 2008 15:58:45 GMT</pubDate><dc:creator>Larry Tucker</dc:creator></item><item><title>RE: Error:  The DataSourceKey [] is not defined.</title><link>http://forum.strataframe.net/FindPost15740.aspx</link><description>Okay.&amp;nbsp; Thanks for the clarification.&amp;nbsp; &lt;P&gt;I understand the&amp;nbsp;DataLayer.DataSources.Add() is where the item&amp;nbsp;is created in the collection.&amp;nbsp;&amp;nbsp;I meant that&amp;nbsp;I would have expected it&amp;nbsp;to return&amp;nbsp;some sort of failure warning / exception if it had &lt;U&gt;not&lt;/U&gt; created the DataSourceItem.&amp;nbsp; It never occurred to me that a web app could run without the app_start firing :crazy:&lt;/P&gt;&lt;P&gt;Moving from the self-contained world of VFP to this disconnected / remote environment is tough.&amp;nbsp; There are layers upon layers of things that can go wrong.&amp;nbsp; Sometimes it feels like visiting a foreign country where you miss things that are obvious to&amp;nbsp;the local residents because you don't know the context of the culture / language.&amp;nbsp; Bet you never considered yourself a "tour guide".;)&lt;P&gt;Again, your support is much appreciated.&amp;nbsp;&amp;nbsp; I'm doing a lot of reading and troubleshooting before resorting to your guidance.&lt;P&gt;-- Larry</description><pubDate>Thu, 17 Apr 2008 14:48:40 GMT</pubDate><dc:creator>Larry Tucker</dc:creator></item><item><title>RE: Error:  The DataSourceKey [] is not defined.</title><link>http://forum.strataframe.net/FindPost15733.aspx</link><description>[quote]Could you explain how you came up with this?&amp;nbsp; The DataSource collection isn't mentioned in the error message. &amp;nbsp;How did you go from "DataSourceKey [] is not defined" to "missing DataSource item"?[/quote]&lt;/P&gt;&lt;P&gt;Well, a data source key is comes from the DataSourcesCollection.&amp;nbsp; The key means absolutely nothing if it doesn't exist in the data sources collection.&amp;nbsp; This is set in the Application_Start in the global.asax when&amp;nbsp; you add your data source item to the &lt;U&gt;data source collection.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;That's how I went there. :)&lt;/P&gt;&lt;P&gt;[quote]Wouldn't the DataLayer.DataSources.Add() fail in the Global.asax file&amp;nbsp;if the datasource was not added?&amp;nbsp; [/quote]&lt;/P&gt;&lt;P&gt;That &lt;STRONG&gt;&lt;EM&gt;&lt;U&gt;IS&lt;/U&gt;&lt;/EM&gt;&lt;/STRONG&gt; the data source collection.&amp;nbsp; DataSources is a colleciton of data source items.&lt;/P&gt;&lt;P&gt;[quote]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?&amp;nbsp; [/quote]&lt;/P&gt;&lt;P&gt;Yup.&amp;nbsp; 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.&amp;nbsp; By this time the data source item within the collection apparently is not there.&amp;nbsp; 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.&amp;nbsp; Do you even know if the Application_Start is evern happening on the hosted site?&amp;nbsp; That is the first thing I would check.</description><pubDate>Thu, 17 Apr 2008 12:49:57 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Error:  The DataSourceKey [] is not defined.</title><link>http://forum.strataframe.net/FindPost15731.aspx</link><description>[quote]The hosted environment doesn't have the DataSources collection populated when the BO is referencing it, thus it throws the error.[/quote]&lt;P&gt;Could you explain how you came up with this?&amp;nbsp; The DataSource collection isn't mentioned in the error message. &amp;nbsp;How did you go from "DataSourceKey [] is not defined" to "missing DataSource item"?&lt;/P&gt;&lt;P&gt;[quote]You might write to a log file or something when the connection is created to ensure that the data source is being added.[/quote]&lt;/P&gt;&lt;P&gt;Again, I need more information.&amp;nbsp; Wouldn't the DataLayer.DataSources.Add() fail in the Global.asax file&amp;nbsp;if the datasource was not added?&amp;nbsp; 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?&amp;nbsp; &lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Larry</description><pubDate>Thu, 17 Apr 2008 12:00:08 GMT</pubDate><dc:creator>Larry Tucker</dc:creator></item><item><title>RE: Error:  The DataSourceKey [] is not defined.</title><link>http://forum.strataframe.net/FindPost15715.aspx</link><description>The issue is actually straight forward in the sense of the error.&amp;nbsp; The hosted environment doesn't have the DataSources collection populated when the BO is referencing it, thus it throws the error.&amp;nbsp; You might write to a log file or something when the connection is created to ensure that the data source is being added.&amp;nbsp; The hosted environment may also be resetting the application pool, sessions,&amp;nbsp;or something along those which is loosing instantiated objects.</description><pubDate>Wed, 16 Apr 2008 20:03:12 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>