Click here to Skip to main content
11,805,266 members (64,449 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# C#4.0
i want upload only .csv format files in my web page and as soon as i click on Update button it will automatically create table with columns
file name= table name and
first row of the file (headings)= columns of the table

how to write the code for it in MS SQL server. .
Posted 1-Oct-12 3:11am

1 solution

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

Solution 1

First you need to know how to execute SQL code.

The following describes that how to execute SQL statements from c#.[^]

Then you need to read in the CSV to get the structure of the file. One such reader is available on CodeProject Smile | :)

A Fast CSV Reader[^]

Next you need to construct an SQL statement which creates the table. The following explains the CREATE TABLE command is SQL.[^]

Then you need to execute this command against SQL.

Then you need to read the data in with your CSV reader and insert into the new table.

The following is information on the INSERT command.[^]

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

  Print Answers RSS
0 OriginalGriff 315
1 Sergey Alexandrovich Kryukov 210
2 Richard Deeming 200
3 CPallini 160
4 CHill60 150
0 OriginalGriff 3,265
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 2 Oct 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