Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

Write a program to show connection to Excel in ASP.NET?
OleDbConnection x;
    OleDbCommand y;
    OleDbDataReader z;
    protected void Page_Load(object sender, EventArgs e)
    {
        x = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=c:\book1.xls;Extended Properties=excel 8.0");
        x.Open();
        y = new OleDbCommand("select * from [sheet1$]", x);
        z = y.ExecuteReader();
        while (z.Read())
        {
            Response.Write("<li>");
            Response.Write(z["ename"]);
        }    
        z.Close();
        y.Dispose(); 
        x.Close(); 
    }