Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 22nd, 2006, 03:30 AM
wk wk is offline
Authorized User
 
Join Date: Aug 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Read excel file into database

Dear all,

May I know how can i read an excel file into database. I'm using visual studio 2005 and c#

Thanks

wk

 
Old August 22nd, 2006, 09:58 AM
Friend of Wrox
 
Join Date: Feb 2006
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I previously used DTS (Data Transformation Services) to successfully upload Excel Spreadsheets into SQL Server 2000.

For Sql Server 2005 I think what you want to look up is Sql Server Integration Services, which replaced DTS.

Neil Timmerman
Programmer II
School of Medicine
University of Missouri Columbia
 
Old August 22nd, 2006, 08:02 PM
wk wk is offline
Authorized User
 
Join Date: Aug 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

T
hanks, I'm using sql server 2k as well. :)

But is there a way to read the excel file into database by writing it in c#?
 
Old August 23rd, 2006, 10:07 AM
Friend of Wrox
 
Join Date: Feb 2006
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's really easy to upload an excel spreadsheet using DTS in SQL Server 2k and it works great and you can do it using a wizard-like point and click interface in the enterprise manager.

To do this, right click over a table (any table), select "All Tasks", then "Import Data...", and that brings up the DTS Import/Export Wizard. For data source, select "Excel 97-2000". Either that or save your file in CSV format and use one of the *.csv drivers. From there it's pretty easy. You have to make sure the data in your spreadsheet can be converted to the datatypes on the columns in the table you are uploading to. Watch the dates. In my experience its often been easiest to make a new table with no constraints of any kind, and varchar everything, import the data into that table, then use SQL to "massage" it into what I want, and THEN import it to the table(s) I actually want it in.

I don't understand what you mean by "writing it in C#". What do you want to write in C#? A windows form? An ASP.NET site? If you are making an upload form in ASP you will need Office Web Components (OWC).

Neil Timmerman
Programmer
Veris Consulting
 
Old August 23rd, 2006, 10:20 PM
wk wk is offline
Authorized User
 
Join Date: Aug 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Neil,

Sorry for misleading you. Please correct me if I'm wrong.

I have an empty DB currently and I need the uploaded excel files from my users to fill in the data in my DB. I know I can do that by using the DTS but as my users will append the data in the same excel files and upload it again and again so I'm thinking of writing a C# code which is put together in the upload page from the users so that when the excel files are uploaded by users to the server then the appended data will be automatically fill in my db as well. I have the solution on how to retrieve all of the data from the excel files but now my problem is I don't know how to write it to the database.

Hope this make sense.
 
Old August 24th, 2006, 10:44 PM
wk wk is offline
Authorized User
 
Join Date: Aug 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Problem solved :)

 
Old September 6th, 2006, 11:52 AM
Registered User
 
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by wk
 Problem solved :)

Hi WK

Can you tell me how it got solved. I am also in your situation. Only difference is this would be a browser upload.
 
Old June 12th, 2007, 06:53 AM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi WK

Can you tell me how it got solved. I am also in your situation.






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read data from an excel file diegoblin Beginning VB 6 6 August 31st, 2009 11:04 PM
Read Data from Excel File kiwibey ASP.NET 2.0 Professional 1 December 5th, 2006 11:27 AM
how can read excel file abrahamchempanal RSS and Atom 0 February 22nd, 2006 10:52 AM
Read Excel File rekha_jsr Classic ASP Basics 2 June 16th, 2005 04:58 AM
Read an uploaded Excel File rekha_jsr Classic ASP Basics 0 June 12th, 2005 10:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.