I am building a quiz application which has 5 categories. I am saving details like name, category and score to DB. Table where all data is saved looks like :
Name Category Score
John Windows 10
Tom Mac 5
On the start page i want to disable/enable categories if user has/has not took quiz yet (ie. if John has already completed Windows quiz but hasn’t Mac then enable Mac Quiz, disable Windows and show Windows score).
Whats the most elegant way of retrieving these values from database and then passing them to variable or boolean? What if search returns NULL (if quiz was not taken by John) and manipulating output from SQL Database? I am using vb.net 2.0 and SQL server 2005 and its an asp.net application. ANy help will be greatly appreciated 🙂
Use an ORM such as nHibernate. You can specify default values, and in the event of a null search result, you can instantiate a business/DTO object directly and pre-fill it with whatever you’d like.
If that’s too much – you can always iterate through a datatable (if that’s what you’re returning from the SQL query).