title: Best practice for saving application-level data to database (ASP.NET)
body: <p>We have a very large HTML form (> 100 fields) that updates a SQL Server database with user-entered data. It will take the user a long time to fill out the form, but every piece of information they submit is very valuable to the business process. Even if the user gives up on the form, we want to retain everything they have entered.</p>
  
  <p>We plan to attach an onblur event to each field and use jQuery/AJAX to post each piece of data back to the application server immediately. That part is pretty straightforward. The question we have is when and how to best save this application-level information to the database. Again, our priority is data retention as opposed to performance but we also want to do this as efficiently as possible.</p>
  
  <p>Options as I see it are:</p>
  
  <ol>
  <li>Have the web service immediately post each piece of data to the database server.</li>
  <li>Store the information in a custom class on the application server, then periodically call an update method to post new data to the database.</li>
  <li>Store the information in view or session state, then run a routine to post this information to the database server.</li>
  <li>Something else that we haven't thought of.</li>
  </ol>
  
  <p>Option 1 seems the most obviously failsafe, but also the most resource intensive. Option 2 seems the most elegant, but can we be absolutely certain that the custom class instance can't be destroyed without first running its update method?</p>
  
  <p>Thanks for your help!</p>