array and mssql db

ssfftt

Well-known member
Joined
Oct 27, 2005
Messages
163
Programming Experience
1-3
I use mssql db, i want to load a table into an array, i only need some of the columns, not all. Do i need couple of one dimensional arrays to hold these columns' data or a multidimensional array to hold em?To make myself more clear, i have a table QUESTIONS that contains columns: QID, QDETAILS, QMARKS, QDEFAULTANSWER. I also have a table ANSWERS that contains columns: AID, QID(fk), RID(fk), ACTUALANSWER, MARKSGAINED. I want to load the data in table QUESTIONS into array(s), and when user inputs actual answer and clicks on submit button, i put the actual answer into table ANSWERS, and check answers with the data in column QDEFAULTANSWER in table QUESTIONS. If the answer is correct, gives full marks into COLUMN MARKSGAINED into table ANSWERS. at the end, when user clicks on "mark the whole test", i want to create a new record that contains history of this particular test, i.e. in table RECORD that contains columns: RID, QID, TOTALMARKS, DATE,TIME. There is another way to do it without array, is to communicate to db all time, i.e. to update all the tables once a question is answered and use sqlcommand to compare the answer, give or not give marks. etc. I think this is a silly way because it's better to only talk to db at begining and end of the test. one of the bad things might be: if the app fails during the test, user lose all the answers already done and can be frustrating.I need to experienced suggestions on which way to choose, can any help plz? if array is a better way, plz be more specific in coding, especially in loading the data into array and updating data into db. Otherwise i think i might be able to work out how to do without array myself
 
THX jmcilhinney, thats what exactly i was thinking, however, it might be argued that heavily involving database is not a best idea because some processes can be done much faster locally rather than having to communicate to db all the time. Speed is not a big issue for my app because it's fairly small and the db is hosted locally. however, in enterprise app, it might be concerned? just discussion of interest, i will stop if its suggested not worth to talk about
 
There is no heavy involvement with the database. The whole idea with ADO.NET is that it's disconnected. You retrieve all the data you need into a DataTable and then you disconnect form the database. You make whatever changes you want to make to the data locally and then you only connect to the database again when you are ready to commit all the changes. A DataTable is no more connected to the database than your arrays would be, except that its structure mimics that of the database so it is easier to work with. I think it would serve you well to do a little reading on ADO.NET.
 
Back
Top