Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear sir!
I want to add access file or excel sheet as ole objects.
how can i do this.
which property of the form will be used.
Posted
Updated 29-Jun-11 11:45am
v2
Comments
keyboard warrior 29-Jun-11 17:48pm    
changed shhet to sheet.

something similar to this. just a guess.

using System.Data.OleDb;


string strConn;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\Somehwere\\Somehwere\\App_Data\\FILE.xls; Extended Properties=Excel 8.0;";

//You must use the $ after the object you reference in the spreadsheet

OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn);

DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet, "ExcelInfo");

foreach (DataRow theRow in myDataSet.Tables["ExcelInfo"].Rows)
{
  Console.WriteLine(theRow[0].ToString());	
}
 
Share this answer
 
v3
As far as I knew, OLE is not supported in any of the .NET controls out-of-the-box. There may be third party controls out there that do, but I have no idea which ones, if any. It's not something I ever had to look into.
 
Share this answer
 

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