Click here to Skip to main content
11,705,762 members (50,383 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
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.

Thanks
Posted 12-Nov-12 9:16am
Comments
Nelek at 12-Nov-12 15:17pm
   
Orcun Iyigun at 12-Nov-12 17:08pm
   
I love this link. added to my favourites :)
Sergey Alexandrovich Kryukov at 12-Nov-12 16:29pm
   
"I am having trouble" is not informative. What's the problem? Any code sample?
--SA
ryanb31 at 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
good
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#[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 213
1 Sergey Alexandrovich Kryukov 170
2 Inimicos 60
3 ProgramFOX 50
4 Richard MacCutchan 45
0 OriginalGriff 9,037
1 Sergey Alexandrovich Kryukov 8,417
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 13 Nov 2012
Copyright © CodeProject, 1999-2015
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