Import Excel file via ASP to SQL

  • Hi,

    I'm looking for ways to allow a user to upload an excel file into SQL Database, using ASP!

    The current method we are working on:

    1. ASP to allow user to upload the file on Web Server

    2. ASP will connect to SQL and insert into a temp table row by row

    3. A procedure on SQL is launched to do data checking

    4. Good records will be availabe via ASP for user to continue processing.

    Obviously, using Excel is not too good due to possible macro viruses.  Security Administrator is asking us to use CSV, which seems to be appropriate.

  • There are several ways to achieve what you want to do, but the level of access that your SQL Server login has will most likely determine the outcome.

    I have in the past used CSV files uploaded to the server, which are then parsed in ASP and finally Bulk Inserted into a temporary table, after which you can do what ever you need to. Even this approach requires that the login has Bulk Insert privileges.

    The other neat way to do this is to use a DTS package which could take the uploaded Excel file and import it directly, but this is a bit of a security nightmare, especially on shared environments. There are lots of examples of how to call the DTS package from ASP but your SQL login needs some additional privileges beyond the norm. 

    I'm certainly no expert in this and I'm sure someone else will offer even further alternatives.

  • I am posting not as a reply to the actual question, but to find out how I can do the opposite of it.

    ie., if a user generates a report (basically as a result of querying database table(s) via ASP), can I convert it (output report) into excel file on the server side and provide a link on the webpage to download for the user?

    thank you,

    v

  • Well the most common approach would be write a CSV file to the server or directly to the browser. You could also use a reporting tool such as Excel Writer from Soft Artisans, mind you its expensive or perhaps investigate the new SQL Server Reporting function which I believe could do exactly what you want, and its a free upgrade for existing owners of SQL Server 2000.

    There are no doubt several other ways too, but I hope this helps.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply