Issue when reading data from excel sheet 
June 26th, 2009, 05:29 AM
|  | Member | | Join Date: Apr 2007
Posts: 89
| | |
Hi Friends
I am getting the following error when I am trying to read data from an excel sheet using sql script OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. The provider did not give any information about the error.
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IDBInitialize::Initialize returned 0x80004005: The provider did not give any information about the error.].
If I save the excel file in the database server machine, then it will work fine.. I am getting this error message when I save the excel file in any other machine in the network and trying to read data from that excel sheet
I am using the following code
Select @PowerFileName = '\\xxx.xxx.x.xxx\upload\Data_Sheet.xls'
EXEC MASTER..XP_CMDSHELL @cmd, NO_OUTPUT
set @provider = 'Microsoft.Jet.OLEDB.4.0'
set @ExcelString = 'Excel 5.0;Database=' + @PowerFileName
EXEC ('select * into tbl_BaseLoad from OPENrowset(''' + @provider + ''',''' + @ExcelString + ''',''SELECT * FROM [baseload$] WHERE F3 IS NOT NULL UNION SELECT * FROM [baseload$] WHERE F2='+ @CurrentDateNumber +''')')
Please help me
Ammooss
| 
June 26th, 2009, 05:00 PM
|  | Expert | | Join Date: Jun 2007
Posts: 1,914
Provided Answers: 1 | | | re: Issue when reading data from excel sheet
Can you access that machine from the SQL Server?
-- CK
| 
June 29th, 2009, 12:26 PM
|  | Member | | Join Date: Apr 2007
Posts: 89
| | | re: Issue when reading data from excel sheet
Yes.. I can access that machine from sql server machine
| 
June 30th, 2009, 07:50 AM
|  | Expert | | Join Date: Jun 2007
Posts: 1,914
Provided Answers: 1 | | | re: Issue when reading data from excel sheet
How do you access the remote machine?
-- CK
| 
June 30th, 2009, 11:33 AM
|  | Member | | Join Date: Apr 2007
Posts: 89
| | | re: Issue when reading data from excel sheet
Sorry..I couldnt understand your question.. I access the remote machine using the IP via the Run
| 
June 30th, 2009, 09:10 PM
|  | Expert | | Join Date: Jun 2007
Posts: 1,914
Provided Answers: 1 | | | re: Issue when reading data from excel sheet
I mean accessing inside the SQL Server. The RUN command is on the OS level, not inside SQL Server. Have you tried accessing the remote machine from SQL Server via IP?
--- CK
| 
July 1st, 2009, 06:31 AM
|  | Member | | Join Date: Apr 2007
Posts: 89
| | | re: Issue when reading data from excel sheet
CK
I am not sure how to access the remote machine from SQL Server via IP.. Can you pls help me?
Ammooss
| 
July 1st, 2009, 10:15 AM
|  | Member | | Join Date: Apr 2007
Posts: 89
| | | re: Issue when reading data from excel sheet
CK
I just tried to copy the same excel file from remote machine to the server machine using the following code.. but that time I got the message "Access is denied"
declare @msg varchar(3000)
declare @file varchar(1000)
declare @file1 varchar(1000)
set @file = '\\remote macine IP\folder\Data_Sheet.xls'
set @file1 = '\\server machine IP\folder\Data_Sheet1.xls'
SET @msg = 'copy "' + @file + '" "' + @file1 + '"';
exec master.dbo.xp_cmdshell @msg
but this code works fine if I try to copy a file from one folder in the server machine to another folder
Ammooss
| 
July 1st, 2009, 05:41 PM
|  | Expert | | Join Date: Jun 2007
Posts: 1,914
Provided Answers: 1 | | | re: Issue when reading data from excel sheet
Here, read this first.
Good luck!
--- CK
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,652 network members.
|