Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends
This is my stored procedure
SQL
alter procedure sp_excelfortest
 as
-- declare @datavar varchar(200)
 declare @sql varchar(500)
-- set @datavar  = 'Excel 8.0;DATASOURCE=' + @filname

 set nocount on
  begin
  --create table #temptable (Date date ,Day varchar(30),Reason varchar(100))
  --set @sql = (SELECT *  FROM OPENDATASOURCE('Microsoft.jet.OLEDB.4.0','+@datavar +;HDR=YES','SELECT Data,Day,Reason FROM [Sheet1$]')
  Set @sql ='select * FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'',
 ''Excel 8.0;Database=D:\baskarbook1.xls;HDR=YES;'',
  ''SELECT * FROM [Sheet1$]'')'
  exec (@sql)
 end


This works onetime successfully but when i restart the sql server it shows some error.
The error is
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Unspecified error".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".

I dont know how to solve it.and i red some article regarding with this error,but i couldnt get correct solution.please help me
Posted
Comments
Kamalkant(kk) 24-Aug-12 4:32am    
Which version of sql server have u used?
baskaran chellasamy 24-Aug-12 4:48am    
sql server2008

Try this query in sql server 2005 and set the Configuration--> sql server surface area configuration-->..
 
Share this answer
 
Possible reason is file is open, permission issue, file is locked for read.
Try close file if it is open & give some more permission (try giving full permission may be when first time file read it may be going in lock).
Go through these link
http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/83300532-e780-4ac6-9a64-7246e58c253a
http://blogs.msdn.com/b/spike/archive/2008/07/23/ole-db-provider-microsoft-jet-oledb-4-0-for-linked-server-null-returned-message-unspecified-error.aspx
 
Share this answer
 
Comments
baskaran chellasamy 24-Aug-12 4:56am    
I studied the above articles and check the permission on temp folder.all the user in my system has permission to write and read and everything. but still the error occurs.if the excel file is locked mean how can i unlocked
pradiprenushe 24-Aug-12 4:59am    
1. Close xls file if it open
2. Right click xls file go to security add user Asp.net & give full permission to Asp.Net user.
baskaran chellasamy 24-Aug-12 5:01am    
Now i created another one excel file to execute. but this time the new excel file is also not executed. the same error occurs.
pradiprenushe 24-Aug-12 5:12am    
Are you sure sp working for first time?
baskaran chellasamy 24-Aug-12 5:14am    
yes i am sure first time its working. then after i shut down and restart the system and then only its not working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900