How To Import "IRREGULAR" Excel Data Into MySQL Using C#
===

I have a project where i will have to import data from multiple Excel sheets in a document into a MySQL database.The tutorials i have seen assume a straighforward approach where each cell is inserted into a seperate column in a database.My case is a bit different because each cell has different data that needs to go into  seperate columns in the database.
An example is shown below:

                           

                         
                    GST 111		        GST 112		         GST 114	
                     2                     2                   2


    03/ED/SE        54                     52                 53            Bio111
                                                                             54
As seen above,the heading of "GST 111" represents the course title, while the value of "03/ED/SE" represents the registration number. The values of 54,52 and 53 represent the scores of the student with reg.no  "03/ED/SE"  in the courses with codes :"GST 111", "GST 112" and "GST 114". Things get a little tricky when the value  
                          
                          "Bi0111"
                            54
 is reached. This is because in that instance, the column contains values for both the course code, .i.e "Bio111" and the score , .i.e "54"...this happens in each instance the student has a carry-over course. The challenge is to be able to insert the "Bio111" into the column for course codes and 54 for course scores, both of which are in the same cell in the same column.
The code i have is this:

                  

                 protected void insertdata_Click(object sender, EventArgs e)
    {
        OleDbConnection oconn = new OleDbConnection
		(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + 
		Server.MapPath("example.xls") + ";
		Extended Properties=Excel 8.0");//OledbConnection and 
				// connectionstring to connect to the Excel Sheet
        try
        {
            //After connecting to the Excel sheet here we are selecting the data 
	   //using select statement from the Excel sheet
	   OleDbCommand ocmd = new OleDbCommand("select * from [Sheet1$]", oconn);
	            oconn.Open();  //Here [Sheet1$] is the name of the sheet 
				//in the Excel file where the data is present
            OleDbDataReader odr = ocmd.ExecuteReader();
            string fname = "";
            string lname = "";
            string mobnum = "";
            string city = "";
            string state = "";
            string zip = "";
            while (odr.Read())
            {
                fname = valid(odr, 0);//Here we are calling the valid method
                lname = valid(odr, 1);
                mobnum = valid(odr, 2);
                city = valid(odr, 3);
                state = valid(odr, 4);
                zip = valid(odr, 5);
                //Here using this method we are inserting the data into the database
	       insertdataintosql(fname, lname, mobnum, city, state, zip);
            }
            oconn.Close();
        }
        catch (DataException ee)
        {
            lblmsg.Text = ee.Message;
            lblmsg.ForeColor = System.Drawing.Color.Red;
        }
        finally
        {
            lblmsg.Text = "Data Inserted Sucessfully";
            lblmsg.ForeColor = System.Drawing.Color.Green;
        }
           
This code will work for a single sheet with properly structured data, which is not the case with me as i have shown.(I have myultiple sheets and multiple data in some cells).How can i resolve this?.
Thanks.


