web service

marky102
marky102 used Ask the Experts™
on
how do i go about writing a .csv excel file 2007 data to sql2008 using a web service ?

what is the best approach ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
First you would need a file upload control to get the csv from the client to the server for reading and processing the data. Then you can read the stream of data line by line to parse the info. As an alternative, if you have written DTS/SSIS packages, you can reduce the amount of code you need to write and just have a sql package handle the formatting and processing of the file to the table.

Just a few best practices i've come up with:
-Track the original name of the file, give is a transaction number in a separate table and attach that transaction number to each record that get entered to generate a trail, as well as the who and when the upload was done.
-verify it is a valid csv file (http://www.codeproject.com/Tips/272726/validate-csv-file-vb-net)
-generate a sql transaction so if it fails halfway through from bad data, the whole import can be reverse.

Author

Commented:
i would like to upload a file to a web server, and use the upload command, and not write to file. it is easy to do in an asp project or c# project, but i would like to do it in a web service.
So you want to send the service the file and have the service write the records to the database?

If that is the case then just use the code from a regular asp.net project that does this and use it in the service. Consume the service from your application and pass the file stream as the input for the service. If you expect to work with very large files things will be a lot trickier.

Author

Commented:
good approach

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