Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'd like to know how to Import excel file to SQL Server 2008. For Example I have a textbox, browse button, and import button. I will click browse and will browse for the excel file then click import to INSERT INTO the specific table in the database all the data in the excel file (not create new table). Is there anyone who knows the codes for this? and where to put them? thank you very much. :)

share|improve this question
That's quite a task and there are multiple ways to do it. As with every programming problem, I suggest breaking it down to smaller steps and researching how to solve each one. Steps like "How to read a file", "How to create classes/objects in C#", "how to parse strings", "excel reader libraries", "How to connect to a database" and so on... – Reza Shirazian May 31 at 2:46
I've been searching for hours and I cant understand most of the things i read. They just gave me this work yesterday and due later and I have no idea about this. This is the only way I can think of, asking here. I'm sorry for my question. Thanks! :) – jeeeee May 31 at 2:53
1  
I cant understand most of the things I read. Coding isn't something you pick up and understand in a day, it takes years. Please read a book to learn how to understand it. stackoverflow.com/questions/194812/… – Jeremy Thompson May 31 at 5:40

1 Answer

I haven't tried this one but I think it will have two major steps.

  1. You have to create a function that can open and read the content of the excel file
    Referece: How to open an Excel file in C#?
  2. Read the content of excel file and import to database tables
    Reference: http://www.codeproject.com/Articles/14528/Generate-SQL-INSERT-commands-programmatically
    For creating new table:
    create sql table programmatically

Hope that could give ideas.

share|improve this answer
im reading it right now thanks.. :) – jeeeee May 31 at 2:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.