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.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Ad hoc access to OLE DB provider 'Microsoft.Jet.OL

Author  Topic 

tsvenumadhav
Starting Member

5 Posts

Posted - 2005-12-26 : 07:15:07
hi...

i am trying to export excel data to sql server table programatically using c#.net.

this is my code



cs=ConfigurationSettings.AppSettings["exportexl"];
SqlConnection con=new SqlConnection();
con.ConnectionString=cs;
con.Open();
string str;
str="Insert into testtbl Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=d:\testids.xls;HDR=YES', 'SELECT * FROM [Sheet1$]')";
SqlCommand cmd = new SqlCommand(str,con);
cmd.ExecuteNonQuery();

when i execute the above code it gives the following error..


Ad hoc access to OLE DB provider 'Microsoft.Jet.OLEDB.4.0' has been denied.
You must access this provider through a linked server..


plese give me some help
   

- Advertisement -