string conn = @"data source=secret server; integrated security=True; initial catalog=secret db;User ID=secret user"; var mapper = new ModelTotableMapper<sqlDataModel>(); mapper.AddMapPing(c => c.datavalue,"datavalue"); using (var dep = new sqltableDependency<sqlDataModel>(conn,"data",mapper)) { dep.OnChanged += Changed; dep.OnStatusChanged += OnStatusChanged; dep.OnError += OnError; dep.TraceLevel = TraceLevel.Verbose; dep.TraceListener = new TextWriterTraceListener(Console.Out); dep.Start(); Console.Writeline("Press a key to exit"); Console.ReadKey(); dep.Stop(); }}static voID OnStatusChanged(object sender,StatusChangedEventArgs e){ Console.Writeline(e.ToString());}static voID OnError(object sender,ErrorEventArgs e){ Console.Writeline(e.ToString());}static voID Changed(object sender,RecordChangedEventArgs<sqlDataModel> e){ if (e.ChangeType != ChangeType.None) { var changedEntity = e.Entity; Console.Writeline("DML operation: " + e.ChangeType); Console.Writeline("value: " + changedEntity.datavalue); }}
以上代码我基于https://tabledependency.codeplex.com/wikipage?title=SqlTableDependency
我确信我有,我正在使用db_owner角色.我启用了代理,我看到在mssql db中创建了trigers,services等.
在目标队列中排队消息时发生异常.错误:
15517,State: 1. Cannot execute as the database principal because the
principal “dbo” does not exist,this type of principal cannot be
impersonated,or you do not have permission.
即使数据库已经给了我完全许可,我还没有做
ALTER AUTHORIZATION ON DATABASE::secret db TO sa总结
以上是内存溢出为你收集整理的c# – 未触发SqlTableDependency onchange事件全部内容,希望文章能够帮你解决c# – 未触发SqlTableDependency onchange事件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)