Since you're dealing with common server location for all users, rename your files to GUID or use sessionId for file names. Don't forget to cleanup the folder.
Alexei Fimine
_____________
"And though I have the gift of prophecy, and understand all mysteries, and all knowledge; and though I have all faith, so that I could remove mountains, and have not charity, I am nothing"
Marked as answer by geniusvishal on Aug 10, 2012 05:51 AM
It is little bit hard to give a complete sample. Here is the way to read data from multiple Excel Sheets into a DataTable. Then save this DataTable to table in DB:
Alexei Fimine
_____________
"And though I have the gift of prophecy, and understand all mysteries, and all knowledge; and though I have all faith, so that I could remove mountains, and have not charity, I am nothing"
geniusvishal
Star
13984 Points
2783 Posts
Inserting Data from Excel to SQL Server
Aug 08, 2012 01:38 PM|LINK
Hello Guys,
I am stuck with this unique problem.. I have this requirement of Inserting Data from Excel Sheet to SQL Server..
I am currently using Microsoft Web Developer 2005 Express, SQL SERVER Express 2005 and Microsoft Excel 2007 (Its version is 12.0 i guess)..
I have done a lot of research in this topic but could not find anything suitable..
I want to insert the path of excel file using File Upload control and when the user clicks the button the Record in the sheet1 of that excel
sheet should get inserted into the relevant table into the database..
The system should work for entering many data simultaneously into the database...
Please suggest a simple way to achieve this goal..
Any relevant links are Welcomed...
Thanks and Regards,
Vishal Ranjan
My Website
www.dotnetvishal.com
Basquiat
Contributor
2378 Points
625 Posts
Re: Inserting Data from Excel to SQL Server
Aug 08, 2012 01:43 PM|LINK
see
http://forums.asp.net/t/1823350.aspx/1?I+am+importing+data+from+Excel+sheet+to+SQL+Server+to+store+in+a+table+using+an+aplication
geniusvishal
Star
13984 Points
2783 Posts
Re: Inserting Data from Excel to SQL Server
Aug 08, 2012 01:57 PM|LINK
Thanks Basquiat for your suggestion..
But How could you seperate multiple data from xcel sheet get separated by comma..???
Another thing is that I want the end user to just insert his excel file and upload the associated data into the database...
My Website
www.dotnetvishal.com
fimine
Contributor
3008 Points
549 Posts
Re: Inserting Data from Excel to SQL Server
Aug 08, 2012 02:07 PM|LINK
Upload your file to a common locatoin, where your app has permission.
Then use Data connection to excel (see here: http://www.connectionstrings.com/excel)
simply select from excel into sql.
Since you're dealing with common server location for all users, rename your files to GUID or use sessionId for file names. Don't forget to cleanup the folder.
_____________
"And though I have the gift of prophecy, and understand all mysteries, and all knowledge; and though I have all faith, so that I could remove mountains, and have not charity, I am nothing"
geniusvishal
Star
13984 Points
2783 Posts
Re: Inserting Data from Excel to SQL Server
Aug 09, 2012 05:12 AM|LINK
Thank You fimine for your response... I want to know more about this.. Do you have any relevant links...
My problem is I always use connection strings in web.config and I have not used it any webpages..
The Second thing is that since the file name always changes how could i configure it in my codes...
Any more relevant information...
Thanks.
My Website
www.dotnetvishal.com
geniusvishal
Star
13984 Points
2783 Posts
Re: Inserting Data from Excel to SQL Server
Aug 09, 2012 06:51 AM|LINK
Any More Suggestion for achieving this goal guys...
My Website
www.dotnetvishal.com
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: Inserting Data from Excel to SQL Server
Aug 09, 2012 08:04 AM|LINK
Hi,
It is little bit hard to give a complete sample. Here is the way to read data from multiple Excel Sheets into a DataTable. Then save this DataTable to table in DB:
http://www.mindfiresolutions.com/Retrieving-Data-From-Excel-Files-Having-Multiple-Worksheets-In-ASP-NET-1944.php
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework
fimine
Contributor
3008 Points
549 Posts
Re: Inserting Data from Excel to SQL Server
Aug 10, 2012 02:42 PM|LINK
This shouldn`t be superhard espceially for "genius vishal". Just set your connection string dynamically in your command object
http://www.codeproject.com/Questions/258310/How-we-set-SQL-Connection-string-dynamically-in-Cs
_____________
"And though I have the gift of prophecy, and understand all mysteries, and all knowledge; and though I have all faith, so that I could remove mountains, and have not charity, I am nothing"