Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Database > Database General Discussion

Database General Discussion General discussion on database related topics

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-01-2008, 9:54 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Nov 2008
Age: 26
Posts: 10
Reputation: 19
corteplaneta is on a distinguished programming path ahead
Default Inefficiently Monitor SQL Database

Hello,

I've been working on an application for my company, and implementing solutions to small problems along the way has caused me quite a bit of trouble.

I'm looking for a quick & dirty way to monitor a MSSQL database for changes. I need to take an image of this database table & at any later, arbitrary point in time, take another image & compare to determine the differences.

I know I could do this with the MSSQL event notification services, but this seems a bit too complex for the more simple application I'm creating.

What I was thinking about doing was creating a serializable object & a serializable strongly typed collection of this object & saving this to disk to store the current image of the db, then, using a timer, every 5 minutes querying the db for a new copy of this info, then comparing the two to see what's in the new db that wasn't in the original.

Can anyone think of a smarter or quicker way to implement this? Any comments would be greatly appreciated!

Thanks!!

-corteplaneta
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-02-2008, 10:29 AM
cjard's Avatar
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,442
Reputation: 807
cjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond repute
Default

Event notification seems harder than dumping the entire DB to disk every 5 minutes and running a compare routine?

Do you drink a lot of coffee?
__________________
DW1 DW2 DW3 DW4 DNU PQ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-02-2008, 1:06 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Nov 2008
Age: 26
Posts: 10
Reputation: 19
corteplaneta is on a distinguished programming path ahead
Default

Haha, well the database table only has ~500 items, and after researching event notification I realized I'd have no idea where to start. If you have any tips I'd be more than glad to pursue that route!

And I don't drink coffee .

Last edited by corteplaneta; 12-02-2008 at 1:15 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-03-2008, 7:58 AM
cjard's Avatar
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,442
Reputation: 807
cjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond repute
Default

Coffee. Bilious substance. Good man.

Right.. Yep.. dumping it out once every five minutes is possible. I'd leave it in the db though, and every 5 minutes run:


SELECT * INTO myTableNow FROM myTable;

SELECT * FROM myTableNow
MINUS
SELECT * FROM myTable5minsAgo;

DROP TABLE myTable5minsAgo;

RENAME TABLE myTableNow TO myTable5minsAgo;


Note MINUS is Oracle's syntax. Something similar should be possible in SQLServer. If it won't do MINUS, then do:

Now LEFT JOIN 5mins ON Now.PK = 5Mins.PK WHERE 5mins.PK IS NULL
__________________
DW1 DW2 DW3 DW4 DNU PQ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 12-03-2008, 10:35 AM
VB.NET Forum Idol
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Feb 2008
Location: USA
Posts: 877
Reputation: 500
MattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond repute
Default

The T-SQL equivalent of MINUS is EXCEPT.

I think this is only available on SQL 2005+ though.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 12-03-2008, 11:27 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Nov 2008
Age: 26
Posts: 10
Reputation: 19
corteplaneta is on a distinguished programming path ahead
Default

Thanks MattP and cjard! I've got so little experience with SQL that I didn't even think of using SQL directly. Any idea the the LINQ to achieve the same end result?

I'm kind of irritated that LINQ doesn't allow me to query my strongly typed collections, either (isn't this ALL LINQ should work on!?!?! Strongly typed collections implement IEnumerable by default, do they not?)

Last edited by corteplaneta; 12-03-2008 at 7:32 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 12-04-2008, 7:10 AM
cjard's Avatar
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,442
Reputation: 807
cjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond repute
Default

Language Integrated Query - Wikipedia, the free encyclopedia seems to indicate it can? Are you using MyCollectableObjectCollection, or something like List<MyCollectableObject> ?
__________________
DW1 DW2 DW3 DW4 DNU PQ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 7:21 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.