Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Excel Imported Into Access
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Excel Imported Into Access

 Post Reply Post Reply
Author
fark View Drop Down
Newbie
Newbie


Joined: 04 November 2003
Location: United States
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote fark Quote  Post ReplyReply Direct Link To This Post Topic: Excel Imported Into Access
    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.

Back to Top
Bullschmidt View Drop Down
Groupie
Groupie


Joined: 31 May 2003
Location: United States
Status: Offline
Points: 72
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bullschmidt Quote  Post ReplyReply Direct Link To This Post 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_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
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.