Click here to Skip to main content
15,881,832 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I don't know if I'm using the correct terminology, but I'm trying to use a unit test, or just a C# class file to pull records from an excel file(sheet) and insert them into a sql Database. Does anyone know of a good tutorial, book, or any resource at all I could learn how to do this. Also what this action is called. I'm saying Unit test because that's what I use at work all the time. The project I'm working on is all C# Class Files, no asp.net files at all. So I kind of need a class file for this as well. Eventually after I get this set up, I would like to repeat this action with any excel file that needs to be inserted into my Database.


Thanks, any help would be appreciated.
I'm also doing this in visual studio 2012. FYI.
Posted

You probably want a Project/Solution with
1) a class to parse the data (see below), and then
2) a 'Database Layer' which can all be in one class for such a simple requirement, to connect to and add data to the table (it might also need to create the table(s) etc)

I'd save the data as a csv/text file and then have (as I noted) a csv parser that you use to parse line by line of the file, calling a method in the Database class to insert the data into a table

It really depends if this is a one-of or you need something more robust for multiple use - if this is the case, you could later switch the csv class for one that can natively handle excel files.

btw, there are oodles of csv parser classes around
 
Share this answer
 
Comments
Commish13 13-Sep-14 21:43pm    
Thanks for your answer. It's a great high level explanation of what I need to do. Unfortunately for me I'm an entry level C# guy, so I'm going to have to use Google to find out how to write code for this project. Do you have any suggestion on what this project is called, or any key words I should use? Once again thanks for the great over view of what I need to do.
Hi Check this given Link



http://www.c-sharpcorner.com/UploadFile/99bb20/import-excel-data-to-sql-server-in-Asp-Net/
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900