-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: raagz
Message 9 in Discussion


Hi,
 
Here is the sample code. using System;
using System.Data;
using System.Data.OleDb;


public class example16
{
public static void Main(string[] args)
{
string ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data 
Source=c:\\temp\\data\\jhs.xls;Extended Properties='Excel 8.0;HDR=YES;'";

string SelectString = "SELECT Name, Street, City FROM [Sheet2$]"; //$ can not be omited

using (OleDbConnection myCon = new OleDbConnection(ConnectString) )
{
if (myCon.State != ConnectionState.Open) //if connection is not open, open it
myCon.Open();

Console.WriteLine("Open database successfully!");

OleDbCommand myCmd = new OleDbCommand(SelectString , myCon) ;
OleDbDataReader myReader = myCmd.ExecuteReader();

while (myReader.Read())
{
Console.WriteLine("{0}/{1}/{2}", myReader.GetString(0), myReader.GetString(1), 
myReader.GetString(2));
}

Console.WriteLine("Read student data successfully!");
myCon.Close();
Console.Read();
}
}
} Also check this 
linkshttp://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B306572http://www.aspfree.com/c/a/ASP.NET-Code/Read-Excel-files-from-ASPNET/Query
 an Excel Worksheet Without using Interop
http://www.knowdotnet.com/articles/exceldatasource.html
http://msdn.microsoft.com/vstudio/office/ThanksRaghavendra
  

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to