Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ingib
Starting Member
5 Posts |
Posted - 2010-09-08 : 09:58:11
|
| hello,I Have a folder that includes multiple excle files (ver 2007), i am trying to loop through each file using vbscript to import its data to sql 2000 using openrowsetbut i am getting this error in the openrowset line "[Microsoft][ODBC sql server driver] [sql server] [OLE/DB provider returned message: the microsoft office access DB engine cannot open or write to the file '', it is already open exclusively by another user or you need permission to view or write its data]code 80040E14source microsoft OLEDB provider for ODBC driversAny help please |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-09 : 03:56:11
|
| As said, close the file before running the queryMadhivananFailing to plan is Planning to fail |
 |
|
|
ingib
Starting Member
5 Posts |
Posted - 2010-09-14 : 06:14:21
|
| thanks for your reply, i already closed it and here is my code, i don't know what's wrongSet fs = CreateObject("Scripting.FileSystemObject")Set objExcel = CreateObject("Excel.Application")'MyFolder=server.mappath("/")Set Folder = fs.GetFolder("D:\work\hr\documents\samples\august")Set fc = Folder.FilesFor Each fil in fc n=fil.name FilePath="D:\work\hr\documents\samples\august\"&n Set objWorkbook = objExcel.Workbooks.open(FilePath) For i = 1 To objWorkbook.Worksheets.Count sheetName=objWorkbook.worksheets(i).Name objWorkbook.close objExcel.Workbooks.close msgbox SheetName con.execute("Insert into ['"&SheetName&"$'] Select * FROM OPENROWSET('Microsoft.ACE.Oledb.12.0','Excel 12.0;HDR=YES;IMEX=1;Database="&FilePath&";HDR=YES;IMEX=1','SELECT * FROM ["&SheetName&"$]')")N.B: i was able to read the sheet names |
 |
|
|
|
|
|