Print Page | Close Window

Excel Imported Into Access

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=9401
Printed Date: 01 April 2026 at 1:00am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Excel Imported Into Access
Posted By: fark
Subject: Excel Imported Into Access
Date Posted: 30 January 2004 at 5:46pm
Excel Import Into Access

I first tried to Import my excel spreadsheet into access with a Windows Script (mainteance script) but a couple cells in some of the columns contain letters and numbers when all the rest of the cells contain numbers only. This confuses the heck out of TransferSpreadsheet and it doesn't work very well.

set oAcc = CreateObject("Access.Application")
oAcc.Visible = True
oAcc.OpenCurrentDatabase "C:\Shipping Database\ShippingDatabase.mdb"
oAcc.DoCMD.TransferSpreadsheet 0,8,"Import","C:\Inetpub\wwwroot\Copy of SHIPPING.xls", True, "'2003'!"
oAcc.UserControl = True

Then I tried ADO.
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "CopyShipShare"

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.ActiveConnection = objConn
objRS.CursorType = 3 'Static cursor.
objRS.LockType = 2 'Pessimistic Lock.
objRS.Source = "Select * from myRange1"
objRS.Open

This works to put everything in recordset so I can work with it. The problem is the Name Range. Is there anyway to tell ADO to Select the whole sheet without opening excel and naming the range of all the cells in the sheet so I can access them? This is a script that needs to run on it's own so I can't open excel every time right before it runs and tell it the range of cell I need. I'm willing to do this in whatever way works if that is WSH or ASP/ADO or automatic export to CSV and then to access. Whatever will do the job. I don't have visual studio so I can't do it with and Application. Thanks for and suggestions.




Replies:
Posted By: Bullschmidt
Date Posted: 05 February 2004 at 7:10am

You can connect to a csv file (which can be opened in Excel and which an Excel file can be converted into) in good form just as you can to a regular database.

And you can have two recordsets open at the same time.

So I'd suggest going through this recordset one row at a time and within this loop add a new record to the "real" database's recordset.

And for help connecting to a text file using the Jet OLE DB provider:
http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderFormicrosoftJetText - http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Pro viders.htm#OLEDBProviderForMicrosoftJetText

And based on the above link realize that the actual filename does NOT go in the connection string - rather it goes in the SQL statement (definitely a little tricky).



-------------
J. Paul Schmidt, Freelance ASP Web Developer
www.Bullschmidt.com - www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net