473,387 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Load Excel to SQL Server using .NET

Not sure if this is correct newsgroup but I figured I had to start
somewhere.

We need to build a Web based application to allow users to choose an Excel
file from their hard drive (or other mapped drive). At that point the
following needs to happen:

Upload the Excel File to the Webserver(or other server) and extract certain
data elements from the many tabs in the sheet. The extracted data needs to
be inserted into various SQL Server tables for reporting/query capabilities.
The good news is the worbook is protected so the data can always be found in
the same cells. However, the data is
scattered across various tabs in the workbook.

Some Assumptions based on existing infrastructure are:

SQL Server will be database
..NET will be used for Web Application

Any recommendations for how this can best be accomplished?

One sample application we have uses an ActiveX control that is called via
ASP/.NET page. This app basically opens the workbook and grabs data from
various cells. My thinking was this
could be used as a starting point to grab data, pass it to SQL Server stored
procs whichwould perform inserts into necessary tables.

I am new to .NET/Web programming so I'm looking for any possible pitfalls.
My research into the sample application above brought up some security
issues with installing and using ActiveX applications but I don't have
enough experience to know if that's a show stopper.

Any advice would be appreciated. Thanks,

Rich

Nov 19 '05 #1
3 1847
The first step is to allow the users to upload the file using the File HTML
control.
Here's more info:
http://SteveOrr.net/articles/EasyUploads.aspx

Once you have the file on your server, you can open it as an ADO.NET
datasource to extract the data.
Here's an example:
http://www.dotnetspider.com/technolo...ages/1080.aspx

Then (of course) just use standard ADO.NET code to insert it into SQL
Server.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Rich Ulichny" <ru******@optonline.net> wrote in message
news:s2****************@fe09.lga...
Not sure if this is correct newsgroup but I figured I had to start
somewhere.

We need to build a Web based application to allow users to choose an Excel
file from their hard drive (or other mapped drive). At that point the
following needs to happen:

Upload the Excel File to the Webserver(or other server) and extract
certain
data elements from the many tabs in the sheet. The extracted data needs
to
be inserted into various SQL Server tables for reporting/query
capabilities.
The good news is the worbook is protected so the data can always be found
in
the same cells. However, the data is
scattered across various tabs in the workbook.

Some Assumptions based on existing infrastructure are:

SQL Server will be database
.NET will be used for Web Application

Any recommendations for how this can best be accomplished?

One sample application we have uses an ActiveX control that is called via
ASP/.NET page. This app basically opens the workbook and grabs data from
various cells. My thinking was this
could be used as a starting point to grab data, pass it to SQL Server
stored
procs whichwould perform inserts into necessary tables.

I am new to .NET/Web programming so I'm looking for any possible pitfalls.
My research into the sample application above brought up some security
issues with installing and using ActiveX applications but I don't have
enough experience to know if that's a show stopper.

Any advice would be appreciated. Thanks,

Rich

Nov 19 '05 #2
http://www.15seconds.com/issue/030909.htm

This is a great article about how to utilize DTS packages from C#.

First off, stay away from ActiveX controls. You are asking for a
disaster and a support nightmare.

Secondly, you have two options; Use the options in the article mentioned
above (creating a DTS package in Sql Server to read and import the Excel
file and then calling that DTS package from .Net). Or, use the Microsoft
Office Interop libraries to open the file from the webserver and read
the values, then pass those values to the stored procs.

IMHO, I would go the DTS approach. Much cleaner and the processing of
the data is done where it should be, on the DB server.

HTH,
~d

Rich Ulichny wrote:
Not sure if this is correct newsgroup but I figured I had to start
somewhere.

We need to build a Web based application to allow users to choose an Excel
file from their hard drive (or other mapped drive). At that point the
following needs to happen:

Upload the Excel File to the Webserver(or other server) and extract certain
data elements from the many tabs in the sheet. The extracted data needs to
be inserted into various SQL Server tables for reporting/query capabilities.
The good news is the worbook is protected so the data can always be found in
the same cells. However, the data is
scattered across various tabs in the workbook.

Some Assumptions based on existing infrastructure are:

SQL Server will be database
..NET will be used for Web Application

Any recommendations for how this can best be accomplished?

One sample application we have uses an ActiveX control that is called via
ASP/.NET page. This app basically opens the workbook and grabs data from
various cells. My thinking was this
could be used as a starting point to grab data, pass it to SQL Server stored
procs whichwould perform inserts into necessary tables.

I am new to .NET/Web programming so I'm looking for any possible pitfalls.
My research into the sample application above brought up some security
issues with installing and using ActiveX applications but I don't have
enough experience to know if that's a show stopper.

Any advice would be appreciated. Thanks,

Rich

Nov 19 '05 #3
RJ
Tht was good advice about upload and then use ADO.NET to read the data.
After some experimenting things were looking good until I hit a snag.

The Excel workbook is password protected and I get the following error:

"Could not decrypt file".

I found this link which seems to explain the problem:

http://support.microsoft.com/default...;EN-US;Q211378

It works fine when the password is removed but I am not in a position to
remove the password from the production spreadsheet. Any workarounds or
suggestions for next steps?

Thanks,

rj

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Vikram | last post by:
Hi, Given below is my task. An user can open the xls file from my website (loaded on the top frame). After filling the Excel, he can click a send button at the bottom frame. By clicking the...
0
by: Mike Knight | last post by:
(I've also posted this problem on microsoft.public.excel.programming) I have a MS Access 2003 Database named "AS400 Fields.mdb". This database contains links to tables on an AS400. In MS...
9
by: hari krishna | last post by:
hi, I want to send the data from dataset information to Excel through ASP.Net. there will be no XL installed on web server. web server is win 2000 server machine. I am using visual basic code in...
3
by: hkappleorange | last post by:
I connect to mdb file using the following codes. How should I modify it if I want to connect to Excel instead ? <%@ Import Namespace="System.Data.OleDb" %> <% Dim conAuthors As...
6
by: kirke | last post by:
Hi, I want to load excel. However, this simple code doesn't work. When I open this page, there's nothign happen, not even 'unable to initiate excel" or othere error message. I have excel in...
4
by: Elavarasi | last post by:
hi I want to import data from excel sheet to ms access database in asp. sample code if possible regards ela...
1
by: =?Utf-8?B?dHRocm9uZQ==?= | last post by:
Hi, I am querying sql server and loading the resulting data into Excel. For character and integer data types, it's working well, but when I pull decimal data and attempt to load it into Excel...
2
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.