Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2005 Sql Server未使用SqlCacheDependency为简单选择查询创建订阅_Sql Server 2005_Sqldependency_Sqlcachedependency - Fatal编程技术网

Sql server 2005 Sql Server未使用SqlCacheDependency为简单选择查询创建订阅

Sql server 2005 Sql Server未使用SqlCacheDependency为简单选择查询创建订阅,sql-server-2005,sqldependency,sqlcachedependency,Sql Server 2005,Sqldependency,Sqlcachedependency,我试图实现一个简单的SQLCacheDependency来缓存asp.net应用程序中的对象 在打破了我的头很长一段时间后,我似乎已经走到了死胡同,认为外面的风景会有所帮助 SqlCommand cmd = new SqlCommand("SELECT UserID,FirstName,MiddleName,LastName,Mobile#,EmailID,FriendlyName,Phone#,AboutMe,Scrap#,JobPosting#,Testimonial#,Blog#,View

我试图实现一个简单的SQLCacheDependency来缓存asp.net应用程序中的对象

在打破了我的头很长一段时间后,我似乎已经走到了死胡同,认为外面的风景会有所帮助

SqlCommand cmd = new SqlCommand("SELECT UserID,FirstName,MiddleName,LastName,Mobile#,EmailID,FriendlyName,Phone#,AboutMe,Scrap#,JobPosting#,Testimonial#,Blog#,Views#,LastVisitedOn,CurrentAddress,City,State,Country,PermanentAddress,HomeTown,Occupation,CurrentEmployer,LanguageSpeak,LanguageWrite,CreatedOn,NeedJob,ProfileRank,Status,CurrentEmployerID,PictureID,ReferredBy,lat,Long,Zoom,Gender,PinCode,PersonalStatus,DOB,PreferredLanguage,EmploymentHistory,AboutFamily,LastSchoolName,HasCertificate,CertificateMonthLength,CertificateDescription,CertificateSchoolUserId,CallTimes,CertificateType,CertificateTypes,Skills FROM mydb.dbo.UserInfo where UserID=10277",con);
System.Web.Caching.SqlCacheDependency dependency = new System.Web.Caching.SqlCacheDependency(cmd);
con.Open();
try
{
       SqlDataReader reader = cmd.ExecuteReader();
       while (reader.Read())
       {
             seUserInfo = new UserInfo(reader, false);
             this.Context.Cache.Add("Sean", seanUserInfo, dependency, System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, new CacheItemRemovedCallback(ItemRemovedCallBack));
       }
}
但一旦添加此项,它就会从缓存中删除。现在,在花了大量时间修复其他可能的原因(为数据库设置ANSI NULL等)之后,我现在遇到了麻烦。从SQLServer探查器中,我看到订阅是使用以下文本数据启动的

<qnev:QNEvent xmlns:qnev="http://schemas.microsoft.com/SQL/Notifications/QueryNotificationProfiler">
<qnev:EventText>subscription fired</qnev:EventText>
<qnev:SubscriptionID>0</qnev:SubscriptionID>
<qnev:NotificationMsg>&lt;qn:QueryNotification xmlns:qn="http://schemas.microsoft.com/SQL/Notifications/QueryNotification" id="0" type="subscribe" source="statement" info="invalid" database_id="0" sid="0x2EB2AC37F2E7FF468D5DE0B591029EE7"&gt;&lt;qn:Message&gt;26119019-fef7-47ee-ac82-3cb56313670d;9fbb5459-bde4-494b-9b7d-8347be2ee4cb&lt;/qn:Message&gt;&lt;/qn:QueryNotification&gt;</qnev:NotificationMsg><qnev:BrokerDlg>9B1E5573-A52F-E111-8152-005056C00008</qnev:BrokerDlg></qnev:QNEvent>

取消订阅
0
qn:QueryNotification xmlns:qn=”http://schemas.microsoft.com/SQL/Notifications/QueryNotification“id=“0”type=“subscribe”source=“statement”info=“invalid”database_id=“0”sid=“0x2EB2C37F2E7FF468D5DE0B591029EE7”qn:Message26119019-fef7-47ee-ac82-3cb56313670d;9fbb5459-bde4-494b-9b7d-8347be2ee4cb/qn:消息/qn:查询通知9B1E5573-A52F-E111-8152-005056C00008
您将注意到type=subscribe和info=invalid。这让我感到惊讶。根据,当“提交的命令包含不支持通知的语句(例如,INSERT或UPDATE)”时会发生这种情况,很明显,这是一个简单的select语句,符合


那么我在这里错过了什么?这是最简单的场景,它不起作用

好的,我在msdn论坛上也问过这个问题,得到了回答。我的问题是,我使用了由三部分组成的限定符mydb.dbo.tablename,而不是由两部分组成的限定符dbo.tablename,这是一个要求