Read open Excel sheet into DataSet?

ThienZ

Well-known member
Joined
Feb 10, 2005
Messages
45
Location
Germany
Hi,

how can I read an open Excelsheet into a dataset? Usually Im using this :
C#:
String sConnectionString =  
	"Provider=Microsoft.Jet.OLEDB.4.0;" + 
	@"Data Source=c:\xlfile.xls;Extended Properties=Excel 8.0;"; 


OleDbConnection objConn = new OleDbConnection(sConnectionString); 

objConn.Open(); 

OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM [Sheet1$]", objConn); 

OleDbDataAdapter myda = new OleDbDataAdapter();
myda.SelectCommand = objCmdSelect;

myda.Fill(ds);

I cant use this way because i cant close the file...

Thx
 
Back
Top