Click here to Skip to main content
13,007,045 members (61,905 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am tring to read data from CSV file and and insert the data into multiple tables.
I am having trouble inserting data into the tables.
could some one help me.

Posted 12-Nov-12 9:16am
Nelek 12-Nov-12 15:17pm
Orcun Iyigun 12-Nov-12 17:08pm
I love this link. added to my favourites :)
Sergey Alexandrovich Kryukov 12-Nov-12 16:29pm
"I am having trouble" is not informative. What's the problem? Any code sample?
ryanb31 12-Nov-12 16:37pm
Where are you stuck at? What do you have so far? There are a million ways to do this but it will depend on what you have, what your table names are, what your variable names are, etc, etc.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Use below code:
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "CSV document(*.csv)|*.csv";
DialogResult result = dialog.ShowDialog();
if (result == DialogResult.OK)
    string csvFile = dialog.FileName;
    Workbook workbook = new Workbook();
    workbook.LoadFromFile(@"..\csvtodatatable.csv", ",");
    Worksheet worksheet = workbook.Worksheets[0];
    System.Data.DataTable t = worksheet.ExportDataTable();
    this.dataGridView1.DataSource = t;

Details can be seen:CSV to Datatable C#[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170628.1 | Last Updated 13 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100