title: Inserting values to a table using generic dictionary
body: <p>Coding Platform: ASP.NET 2.0 WebForms with C# with MySQL as backend</p>
  
  <p>Background</p>
  
  <p>I am currently working on a bug fixing a website.<br>
  One of the table "registrations" have 80 columns.</p>
  
  <p>The Insert/ Update is done through simple sql statements without any parameterized queries.  </p>
  
  <p>Problem</p>
  
  <p>At registration, the user can vary many parameters resulting in atleast 15 kinds of INSERT query. My problem is how to ensure all fields are inserted with their correct value. </p>
  
  <p>So, I created a </p>
  
  <pre><code>Dictionary&lt;string, string&gt; fields = new Dictionary&lt;string, string&gt;();
  
  fields.Add("LoginEmail", MySQL.SingleQuoteSQL(txtLoginEmail.Text));
  fields.Add("Password", MySQL.SingleQuoteSQL(txtLoginPassword.Text));
  
  fields.Add("ContactName", MySQL.SingleQuoteSQL(txtContactName.Text));
  fields.Add("City", MySQL.SingleQuoteSQL(txtCity.Text));
  </code></pre>
  
  <p>My idea was to make a simple insert query like this</p>
  
  <pre><code>INSERT INTO registrations("all keys as comma separated string") VALUES ("all keys as comma separated string") 
  </code></pre>
  
  <p>My questions are</p>
  
  <ol>
  <li>Is Dictionary the best data structure to implement this?</li>
  <li>Does the sorting of keys by generic Dictionary changes key-value indices at the query?</li>
  <li>Best method to fetch all keys into an array and the corresponding values to another matching array.</li>
  </ol>
  
  <p>And also, what are the other better approaches? </p>
  
  <p>P.S: I am maintaining the code and Making an Entity Class mapping the columns to properties and storing the values is not an option in this.</p>