Connecting Tech Pros Worldwide Help | Site Map

Issue when reading data from excel sheet

  #1  
Old June 26th, 2009, 05:29 AM
ammoos's Avatar
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
  #2  
Old June 26th, 2009, 05:00 PM
ck9663's Avatar
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
  #3  
Old June 29th, 2009, 12:26 PM
ammoos's Avatar
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
  #4  
Old June 30th, 2009, 07:50 AM
ck9663's Avatar
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
  #5  
Old June 30th, 2009, 11:33 AM
ammoos's Avatar
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
  #6  
Old June 30th, 2009, 09:10 PM
ck9663's Avatar
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
  #7  
Old July 1st, 2009, 06:31 AM
ammoos's Avatar
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
  #8  
Old July 1st, 2009, 10:15 AM
ammoos's Avatar
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
  #9  
Old July 1st, 2009, 05:41 PM
ck9663's Avatar
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
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
ODBC, Excel, JScript ... where is the synergy? masterdweb answers 0 June 8th, 2007 01:59 AM
Excel automation cj answers 14 September 26th, 2006 04:55 AM
Reading excel file and writing to access table Paul answers 6 November 12th, 2005 08:35 PM