﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » SqlDependency, and how to avoid it.</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sat, 06 Jun 2026 02:32:41 GMT</lastBuildDate><ttl>20</ttl><item><title>SqlDependency, and how to avoid it.</title><link>http://forum.strataframe.net/FindPost11936.aspx</link><description>G'day&lt;P&gt;I've got a form with 3 devexpress grids, each&amp;nbsp;exposes a&amp;nbsp;strataframe BO (Device, Conversation &amp;amp; Arguments) where Device is the parent of Conversation which is the parent of Arguments. All the Parent child filtering works fine. I've just implemented a method to duplicate the selected Conversation and its child Agruments, providing a new name and new guids to the new rows, and FKs. My problem is that I get an InvalidOperationException as follows:&lt;/P&gt;&lt;P&gt;System.InvalidOperationException was unhandled by user code&lt;BR&gt;&amp;nbsp; Message="When using SqlDependency without providing an options value, SqlDependency.Start() must be called prior to execution of a command added to the SqlDependency instance."&lt;BR&gt;&amp;nbsp; Source="System.Data"&lt;BR&gt;&amp;nbsp; StackTrace:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlDependency.GetDefaultComposedOptions(String server, String failoverServer, IdentityUserNamePair identityUser, String database)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlCommand.CheckNotificationStateAndAutoEnlist()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(QueryInformation QueryInfo, OnChangeEventHandler CallBack)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(QueryInformation QueryInfo, Boolean RegisterNotification)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Business.BusinessLayer.FillOrGetByParentPrimaryKey(Object[] ParentPrimaryKeys, Boolean ReplaceCurrentDataTable)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Business.BusinessLayer.FillByParentPrimaryKey(Guid ParentPrimaryKey)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at TMSSystemTableMaint.frmDVC.btnDuplicate_Click(Object sender, EventArgs e) in C:\development\TMS Redevelopment\TMS\TMSSystemTableMaint\frmDVC.vb:line 314&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.OnClick(EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Button.OnClick(EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.WmMouseUp(Message&amp;amp; m, MouseButtons button, Int32 clicks)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ButtonBase.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Button.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.ControlNative&amp;#119;indow.OnMessage(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.ControlNative&amp;#119;indow.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Native&amp;#119;indow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)&lt;/P&gt;&lt;P&gt;This is occuring when trying to add the child record, on the line:&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;[codesnippet]' Clone all the child DCA &lt;BR&gt;boDCACopy.FillByParentPrimaryKey(OldDCVGUID)[/codesnippet]&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;P&gt;I've used the same block of code successfully in several other forms (with other BOs), in the same project and don't have this problem.&lt;/P&gt;&lt;P&gt;I believe that SQLDependancy is tied up with Notifications, and I did play around with notifications in another project in this solution, but I have since removed and turned it off. I've checked in SQL Server Management Studio and there are no Notifications.&lt;/P&gt;&lt;P&gt;Anyone with any ideas?&lt;/P&gt;&lt;P&gt;Peter&lt;BR&gt;</description><pubDate>Mon, 15 Oct 2007 09:19:41 GMT</pubDate><dc:creator>Peter Denton</dc:creator></item><item><title>RE: SqlDependency, and how to avoid it.</title><link>http://forum.strataframe.net/FindPost11976.aspx</link><description>Aha, glad you got it working :)</description><pubDate>Mon, 15 Oct 2007 09:19:41 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: SqlDependency, and how to avoid it.</title><link>http://forum.strataframe.net/FindPost11951.aspx</link><description>Thanks Ben,&lt;/P&gt;&lt;P&gt;Worked like a charm.&lt;/P&gt;&lt;P&gt;I now realise that I created the BO I was having a problem with by copying the one that I was playing around with notifications on. &lt;/P&gt;&lt;P&gt;Peter</description><pubDate>Thu, 11 Oct 2007 19:18:29 GMT</pubDate><dc:creator>Peter Denton</dc:creator></item><item><title>RE: SqlDependency, and how to avoid it.</title><link>http://forum.strataframe.net/FindPost11944.aspx</link><description>There is a property called ReceiveQueryNotifications on the business object and if it's set to False, it won't try to register the QueryNotification, thereby removing the SqlDependency creation.&amp;nbsp; It defaults to False, but it probably got turned on somewhere, so give that a shot.</description><pubDate>Thu, 11 Oct 2007 09:35:00 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>