View Full Version : help with databases
2004-12-24, 12:54 AM
can anyone help me out with a database class. the only thing ive really done with databases in the past was one assignment for uni which was done in java a year ago. and i dont want to code it wrong so king argyle and others have to use access or whatever. so if anyone can write me a class (give you full credit etc) which i pass a video file name, and see if its located in the recordings database, and then returns (via out variables or property methods, or however you feel it would work best) the description, data recorded etc.
i want to add these to "my videos" but i have no idea how to.
i think the helper dll was going to have something like this in it, but i have no idea how far that has come.
merry xmas and all that :P
now i am going to get some last minute shopping done (got birthday money so i can go and buy xmas presents now, i never get to spend that money on myself, birthdays at xmas suck! :P)
Why dont you just iterate through the recordings using the gbpvr dlls there is a class that gives you the recordings and check the filenames. You can then get the programme object.
If you really want to use the database let me know and I will write you a quick method.
I used to have a method that did just this in the original release of the Video Archive plug-in. It may still be in the old source posted on the GBPVR plug-in downloads page. In the new version I cache the recordings collection and fetch them from there as Jorm suggested. It uses more memory but at least it is database independent.
2004-12-24, 04:55 AM
Reven, as the others have said, you can get the vast majority of the information you need from the ScheduledRecording and ScheduleHelper classes. If you use these classes, you'll be pretty much database friendly regardless of the database in use.
Also, if you query the database yourself, then just pull the Database connection string from the Config.xml. And that will connect you to the appropriate database whether it be Access or MSDE. If you are doing basic queries against the database you should be fine. The only point you'll come into potential clashes is if you start to use Functions in your SQL. The main one that causes problem is use of the Now() function in Access SQL. The equivalant for MSDE/Sql Server is getdate().
For what you are looking for, you should be able to use the two classes I mentioned earlier, and it'll be fine.
I have a couple of helper classes I'm working, but they aren't ready for release yet. Should be out with my first cut at the priority scheduling program.
2004-12-24, 06:07 AM
thanks for the response, i was unaware of the scheduledrecording classes, i have a look into them later on.
ill post if i have any problems.
merry xmas everyone.
2004-12-24, 07:30 AM
ok ive played around a little, and this seems to be quite quick
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if(ScheduledRecordings != null)
foreach (ScheduledRecording scheduledRecording in ScheduledRecordings)
if(fullName == scheduledRecording.getFileName())
Description = scheduledRecording.getProgramme().getDescription() ;
if(scheduledRecording.getProgramme().getSubTitle() .Length > 0)
fileName = scheduledRecording.getProgramme().getSubTitle();
ScheduledRecordings is static IList i set when "My Videos" is activated, (its in a FileDetails class, full of fun facts about files :P well size,sort methods,blah blah blah.)
sure iterating thru each and every recording searching for the right one isnt the quickest way of doing something; so if anyone knows a smarter/better way of doing this, please say so. but if not, ill stick with this, it seems to work. just got to play around and check for exceptions and stuff (and have to decide if i want the imdb.com data to override this, you know logic question. pretty boring stuff.)
i just hope that getSubTitle isnt nullable (i first tried the test if getSubtitle() != null, but that didnt work.) ill run loads of tests etc, i doubt ill have this out until after xmas (well since its 8.32pm xmas eve here, so yeah i doubt it :P).
One problem I see is that a programme can be null. *So when you call getProgramme check to make sure it is not null. *It would be null if you did a manual recording and your code should handle it at least.
I do not believe that a subtitle is ever null. *It might just be an empty string which is fine.
If you wanted this logic to run faster not reallly necessary but may be noticable if you have a lot of recordings you can use a Hashtable instead of an IList. *Then you hash based on the filename makes the lookup logrithmic instead of sequential.
2004-12-25, 12:12 AM
yeah i was thinking about the for loop, which wouldnt take that long, the maximum amount of recordings would most likely be about 100 which wouldnt take long at all, even with 1000 recordings going thru them all wouldnt take long, so its not a really biggy. ill add code to make sure the program isnt null (was unaware of that), thanks jorm.
well its xmas day, so merry xmas everyone.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.