VB or C# to import data to SQL

pauledwardian
pauledwardian used Ask the Experts™
on
I am sort of beginner with both C# and vb so I am looking for a code that will import data from excel file into SQL. Does anyone have a sample code that would actually work? I tried a lot of online sample codes but each one gives me a different error. So, please if you have ever done something like this before and you have a code that would work fine post it here. I would really appreciate that.

Thank you,
Paul
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014
Commented:

Author

Commented:
I used the second link (asp) application that you submitted but the lblmsg and GridView1 gives error even though they are there. Can you please try this on your side and yo will see what I mean.

Paul

Author

Commented:
When I tried to change the path for excel file it says "'C:/users/My Computer/desktop/Files/importexcel2sqlserver/importexcel2sqlserver/example.xls' is a physical path, but a virtual path was expected."

Please advice!
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Most Valuable Expert 2012
Top Expert 2014

Commented:
>gives error even though they are there.

What's the error?

Do you need it in winforms or asp.net?

Author

Commented:
That one I fixed. Now I want to know how to define the path for the excel file.
"When I tried to change the path for excel file it says "'C:/users/My Computer/desktop/Files/importexcel2sqlserver/importexcel2sqlserver/example.xls' is a physical path, but a virtual path was expected."

Please advice! "

Thanks!

Author

Commented:
Do I need to create a virtual path? and if I do then how can I do it? Please provide step by step instructions if possible.

Paul
Most Valuable Expert 2012
Top Expert 2014

Commented:
Again, is it for winforms or asp.net?

Author

Commented:
TI is for winform.
I have a tutorial together with source codes for you to download, sure to work.
http://www.youtube.com/watch?v=bF1OAHMDGQw&list=UUTdEQbGbbha8Bj8xFc0gPHQ&feature=plcp
Most Valuable Expert 2012
Top Expert 2014

Commented:
Physical and virtual paths are for ASP.NET. Are you using a webbrowser control?

Author

Commented:
Thanks guys!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial