English 中文(简体)
监测/记录数据库(活动)
原标题:Monitoring /Watching database (activity) programmatically

I was wondering how to monitor a database for changes programmatically. Suppose I want to have a .net application which would run after every 100th or(nth) row insertion or row deletion or updation . how can it be achieved?
I know little about triggers.they can be used to fire executable.
But I heard that it isn t a good practice. Is there any other way?
2]Do database fire events on table updations? and can they be caught in a program?
3]Can SQL reporting services be used here?

(Also assuming that this application is independent from the actual program which does database manipulation.)

最佳回答

SQL Server 2005 introduced query notifications, new functionality that allows an application to request a notification from SQL Server when the results of a query change. Query notifications allow programmers to design applications that query the database only when there is a change to information that the application has previously retrieved.

Check out the MSDN link for more clarity and sample immplementation

问题回答

除非你对“100”或“nth”的准确性表示担忧,否则触发因素实际上将是唯一的。

对2和3的答复是没有的。

您可以撰写经过管理的存储程序(MSDN example , 但这确实有助于你。 一般来说,触发因素可能是不良的做法,因为它们可能阻碍最初的打电话者,但有时是唯一的解决办法。

我认为,你需要质疑把这一低级数据监测单独应用的要求。 考虑您的数据变化可以产生在何处,

各位是否充分了解:

  • stored proc within your db (now and future) and which ones update this table?
  • application that may hit your database (now and future)

否则,在数据一级(如在db范围内)跟踪变化可能是最佳选择,可能意味着触发......。

http://msdn.microsoft.com/en-us/library/ms166104(v=SQL.90).aspx”rel=“nofollow” http://msdn.microsoft.com/en-us/library/ms166104(v=SQL.90)。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签