Connecting Tech Pros Worldwide Forums | Help | Site Map

Issue when reading data from excel sheet

ammoos's Avatar
Member
 
Join Date: Apr 2007
Posts: 91
#1: Jun 26 '09
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

ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,992
#2: Jun 26 '09

re: Issue when reading data from excel sheet


Can you access that machine from the SQL Server?

-- CK
ammoos's Avatar
Member
 
Join Date: Apr 2007
Posts: 91
#3: Jun 29 '09

re: Issue when reading data from excel sheet


Yes.. I can access that machine from sql server machine
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,992
#4: Jun 30 '09

re: Issue when reading data from excel sheet


How do you access the remote machine?

-- CK
ammoos's Avatar
Member
 
Join Date: Apr 2007
Posts: 91
#5: Jun 30 '09

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
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,992
#6: Jun 30 '09

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
ammoos's Avatar
Member
 
Join Date: Apr 2007
Posts: 91
#7: Jul 1 '09

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
ammoos's Avatar
Member
 
Join Date: Apr 2007
Posts: 91
#8: Jul 1 '09

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
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,992
#9: Jul 1 '09

re: Issue when reading data from excel sheet


Here, read this first.

Good luck!

--- CK
Reply