Database Challenge

I have to do some coding for Scoilnet this week-end, but I have to complete another database challenge for another project.

Ok , basics elements first:

  • A questionnaire like a census full of type of yes no questions.
  • This questionnaire is divided in 7 chapters from A to G 
  • More than 100 types of controls for some page, the most complex being the D one.

The datakey is a school number which I use in an Entry table to record the new questionnaire.
I have also 7 tables from B to G with the same fields Id_entry (link to the Entry table), Id_Question and Answer.
On the form I have a Save button to save record by page and a Save All button to save all the pages.

Issue:
When one of the 6 users click the Save button, some pages are very slow to save, it's obvious when they look at the status bar or if I use a trace.
Unfortunatly, randomly this creates a Timeout error page. I identify a network problem, and discover that our network (25 users) is very slow sometime, but ok in evening( of course when nobody there). I can't also have a quick fix on this issue(too long to explain why here).
So I have to turn back to my code, which seems to work perfectly to see how I can optimise the Save function.
I will concentrate mostly only first on this one, because the Save All is absolutly useless, take too much to finish the operation.
Locally on my laptop, it's working very well anyway, but it's true that I am 'my' only user.
So I wonder what I can do to improve this subroutine ?
The different pages are embedded as controls through a Tab Web control.
When I click on Save the routine read the values returned by an hashtable from the control, and send the values and the name of the key to a stored procedure. This SQL procedure check if the question key is already in the table, if yes update the value, if no insert a new key and a new value.
It's true that working like that, I have a lot of roundtrip between my code and SQL, indeed for each textbox or checkbox on the page.

Challenge:

After some long hours of brainstorming ( Well it was really stormy in my brain;-)), I think the solution would be to send to the stored procedure the whole content, like a big chunk of data, using some magic split there, under a Transaction control to get back as quick as possible to the routine.
So I am going to see if I can create a datatable, see how I can send that to SQL, should be not difficult.
The only blur thing here is what about a user who come back to an old questionnaire, read it and want to update ?
Tough challenge for me, maybe easy for gurus developers.
I wonder if it's something that could be answer in the future by .Net 2.0 and Yukon, a way to send a chunk of data to the databse, analyze the data there, and store them.
As usual, if anybody as some leads on that let me know

1 Comment

Comments have been disabled for this content.