Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Next Problem...
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Next Problem...

 Post Reply Post Reply
Author
davidshq View Drop Down
Senior Member
Senior Member


Joined: 29 July 2003
Location: United States
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote davidshq Quote  Post ReplyReply Direct Link To This Post Topic: Next Problem...
    Posted: 01 June 2005 at 10:28am
     My thanks again to all have posted back answers to my questions. I am spending an average of five hours a day writing this newest script and am eager to complete it.
     I have a new question however and this is probably going to be the most difficult I am going to ask.
     Okay, let's imagine that you are building a library program. The database currently includes 200 books. These books are stored in a table called tblBooks. It includes columns such as Title, Author, Publication Date, Description, Popularity, etc.
     Now, you want to make it so patrons can join. Once they join they can have the program select their weekly reading for them. It does this by selecting a random given number of books from the library. However, it has to be smart enough to not keep assigning the same books over and over again.
    So, you want it to find five random books that haven't been read by a given reader within the last month, how do you do it?
    I am currently attempting to use the new Profile feature in ASP.NET 2.0 and as I see it I have two options:
(1)I can create in the profile database a new column for each book and this can be filled with the date.
(2)I can create a hashtable or an array or something of the sort that contains all of the data in one field.
    Usually, I would probably just create a new row, something like UserID, BookID, LastRead. The problem is I am trying to operate w/in the profile feature, and perhaps I should just abandon this, but I am not sure. With the profile if I make an additional row for each book then (I think) I would have to add a definition for each book to the XML Web.Config file, which could become very troublesome.
   Any ideas? I'd like to do this the smart way before I go off doing it the stupid way and end up having to rewrite the whole thing in the end.
David.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 01 June 2005 at 11:21am
You can just use an array stored in the profile column, for example:

create a book class:

public struct Book
{
public int BookId;
public DateTime LastRead;
}

to add a book to the array:

List<Book> readBooks = new List<Book>();
readBooks.AddRange(Profile.ReadBooks);

Book book = new Book();
book.BookId = 7;
book.LastRead = [whatever];

readBooks.Add(book);

to check if the person has read a book

public bool HasUserReadBook(Book book)
{
List<Book> readBooks = new List<Book>();
readBooks.AddRange(Profile.ReadBooks);

return readBooks.Contains(book);
}
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.