Hey guys, tremendous work you all are doing with .netTiers!!
I need to be able to dynamically change the connection string on my Entity Data Source and for the life of me I can't figure it out.
Here is my Entity Data Source and EntityGirdView.
<dataAms:AMSSiteDrugsViewDataSource ID="dsSiteDrugsView" runat="server" EnableCaching="true" EnablePaging="true" EnableTransaction="true" OnSelecting="dsSiteDrugsView_OnSelecting" /> <dataAms:EntityGridView ID="gv3"
AllowExportToExcel="false" runat="server"
DataSourceID="dsSiteDrugsView"
AllowPaging="true"/>
In the code-behind I have tried to change the connection string using the code below:
dsSiteDrugsView.TransactionManager.ConnectionString = "data source=SERVERNAME;initial catalog=XYZ;persist security info=False;user id=XXX;password=XXX;packet size=4096;timeout=300;";
I have tried to do it in both the page_load method and the dsSiteDrugsView_OnSelecting methods. In both methods I get the following error:
Object reference not set to an instance of an object.
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: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 29: {
Line 30: dsSiteDrugsView.TransactionManager.ConnectionString = "data source=xyz;initial catalog=abc;persist security info=False;user id=xxx;password=xxx;packet size=4096;timeout=300;";
Line 31: }
Line 32: |
Source File: C:\Data\Projects\AMS\Tools\MedMined.AMS.Tools.WebSite\Test\t.aspx.cs Line: 30
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
MedMined.AMS.Tools.WebSite.Test.t.Page_Load(Object sender, EventArgs e) in C:\Data\Projects\AMS\Tools\MedMined.AMS.Tools.WebSite\Test\t.aspx.cs:30
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web |
Anyone have any ideas on how I can accomplish my goal of dynamically changing the connection string on the Entity Data Source??
Thanks!!!
David