Skip to content
Advertisement

Read data from excel using column name and insert in to SQL table in C#

I am implementing a system to upload exam marks using Excel sheet. Excel sheet content the student Index number, Name and Grade and the Exams they have taken with Pass/Fail status. Names of the exams and number of exams need to face may vary from student to student.

[Excel sheet format]

I need to save this data into a SQL table in this format

I manage to read the column name from the excel sheet and add it to a list using this code.

Now I need to read the data row by row in the excel sheet using this column names. Can anyone help me please ?

Advertisement

Answer

You can try this:

For this example I have created a class to collect the results by rows that will be destined to SQL:

C#

And the code for read the Excel file:

C#

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement