title: XML to MySQL with C#
body: <p>I need a fastest solution for transferring data from XML file to MySQL tables. 
  I have XML file with multiple tables inside, like this:</p>
  
  <pre><code>&lt;?xml version="1.0" standalone="yes"?&gt;
  &lt;RawData xmlns=""&gt;
    &lt;Table1&gt;
      &lt;ID_Table1&gt;1&lt;/ID_Table1&gt;
      &lt;Name&gt;Victor&lt;/Name&gt;
    &lt;/Table1&gt;
    &lt;Table2&gt;
      &lt;ID_Table2&gt;1&lt;/ID_Table2&gt;
      &lt;Quantity&gt;10&lt;/Quantity&gt;
    &lt;/Table2&gt;
  &lt;/RawData&gt;
  </code></pre>
  
  <p>and within VS2010, i have DataSource with DataTables and TableAdapters from MySql db for Table1 and Table2.
  My goal was to read XML file and pass its data directly to these DataTables with this:</p>
  
  <pre><code>myDSDataSet eDS = (myDSDataSet)this.FindResource("myDS"); // Declared in XAML
  
  OpenFileDialog dlg = new OpenFileDialog();
  dlg.Filter = "XML Files|*.xml";
  dlg.Title = "Select a XML File";
  
  Nullable&lt;bool&gt; result = dlg.ShowDialog();
  
  if (result == true)
  {                  
   mt1TableAdapter mt1_TA = new mt1TableAdapter();
   mt2TableAdapter mt2_TA = new mt2TableAdapter();
   manager = new TableAdapterManager();       
  
   xmlDS = new DataSet();
   dt = null;
  
   try
   {                     
     xmlDS.ReadXml(dlg.FileName,XmlReadMode.InferTypedSchema);
  
     for (int i = 0; i &lt; xmlDS.Tables.Count; i++)
     {                          
       dt = xmlDS.Tables[i].Copy();
  
       eDS.Tables[eDS.Tables.IndexOf(xmlDS.Tables[i].TableName)].Merge(dt);                           
     }
  
     mt1_TA.Update(eDS.mt1);
     mt2_TA.Update(eDS.mt2);
  
     MessageBox.Show("Loading complete.");
   }
   catch (Exception error)
   {
      MessageBox.Show("ERROR: " + error.Message);
   }              
  }
  </code></pre>
  
  <p>But after executing this code i got 2 big problems:
  1. If data types differ i get exception (in DataSource field is DateTime, XML field is read as string)
  2. Calling TableAdapter.Update() takes a long time to save data to db (15k rows takes 10-15mins)</p>
  
  <p>So... my question is, Can someone please help me solve these two problems or give me some direction as to what is the fastest and best method for saving XML data to mysql.</p>
  
  <p>Note: 
  - I'm using VS2010 and MySQL 5.1. 
  - XML file needs to be loaded from external source. 
  - XML has its xmlns but its omitted here for simplicity. 
  - I tried upgrading MySQL to 5.6 and using LOAD XML but i cant use this command within stored procedure.</p>
  
  <p>Thanks</p>