Excel to SQL Server database

This is a discussion on "Excel to SQL Server database" within the Classic ASP section. This forum, and the thread "Excel to SQL Server database are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 14th, 2006, 16:03
Junior Member
Join Date: Feb 2006
Age: 30
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Excel to SQL Server database

Hi,

I have to start working on a ASP which would actually automate the process of exporting the data from excel to SQL Sever database. Can you please tell me how to go about it.

Madhuri
Reply With Quote

  #2 (permalink)  
Old Jun 14th, 2006, 17:09
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Excel to SQL Server database

What experience have you got?
Have you worked with recordsets/connections before?
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #3 (permalink)  
Old Jun 15th, 2006, 08:02
Junior Member
Join Date: Feb 2006
Age: 30
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Excel to SQL Server database

yes I have worked on recordsets and connections before.
Reply With Quote
  #4 (permalink)  
Old Jun 15th, 2006, 10:59
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Excel to SQL Server database

Here's a great website for Connection Strings:
http://www.connectionstrings.com/

This is the idea:
1. Connect to the spreadsheet using this string:
"Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=C:\MyExcel.xls;DefaultDi r=c:\mypath;"

2. Loop through the recordset doing the following...
Code: Select all
 
Do While Not excelRS.EOF
 
sqlRS.AddNew
For Each fld In excelRS.Fields
 sqlRS(fld.Name) = fld.Value ' which is the same as: excelRS(fld.Name)
Next
sqlRS.Update
 
excelRS.MoveNext
Loop
Done!
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #5 (permalink)  
Old Jun 15th, 2006, 11:07
Junior Member
Join Date: Feb 2006
Age: 30
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Excel to SQL Server database

Hi,

I am looking for a code which would help me importing the data in excel sheet to SQL Server table. I am good at connecting strings and stuff. Please let me know how to go about the importing part.

Regards,
Madhuri
Reply With Quote
  #6 (permalink)  
Old Jun 15th, 2006, 11:10
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Excel to SQL Server database

This is an ASP forum so I assumed you wanted to do it in ASP.
What do you not understand about my previous post?
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #7 (permalink)  
Old Jun 15th, 2006, 11:15
Junior Member
Join Date: Feb 2006
Age: 30
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Excel to SQL Server database

I understand the first part where you are trying to make a connection to spreadsheet but sorry I fail to understand the second part.
Do While Not excelRS.EOF

sqlRS.AddNew
For Each fld In excelRS.Fields
sqlRS(fld.Name) = fld.Value ' which is the same as: excelRS(fld.Name)
Next
sqlRS.Update

excelRS.MoveNext
Loop

I would have thought that we would create a table first and export the data from excel to SQL database (using ASP code). Sorry if I have confused you earlier.
Reply With Quote
  #8 (permalink)  
Old Jun 15th, 2006, 20:45
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Excel to SQL Server database

Well, have you used MS SQL before?
What software do you use to manage the database?

My assumption was that:

1. You know how to retrieve information from the excel spreadsheet

2. You have created a table in the SQL database with the same fields and in the same format as the table in the spreadsheet

The code I gave you is an algorithm to do the actual transfer of data from A to B.
It would be easier to help if you gave me some indication of what you have so far, and if you actually had a go at implementing something.

You can't expect me to give you the exact answer to your specific need...
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
Reply

Tags
excel, sql, server, database

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT!!!! Send HTTP request from one web server to another server chandra.nowduri ASP.NET Forum 1 Aug 7th, 2006 19:18
XML Code for transfering data from one SQL Server Database to another database plolla Other Programming Languages 1 Aug 3rd, 2006 18:37
excel -> mysql database riotman Databases 3 Jan 30th, 2006 22:59
Need to process data on one server, utilize it on another server ... can it be done? jaobrien Classic ASP 1 Dec 6th, 2005 00:58
Database connectivity from ASP.NET pages hosted on a free web server? JKidd32 ASP.NET Forum 3 Nov 30th, 2005 18:49


All times are GMT. The time now is 06:23.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43