i tried to import excel file into gridview but the code made this exception (Failed to map this path''xmlTest.x ml") i don't know why
my code:
what i can do?
thanks
my code:
Code:
public void fillGrid()
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("../xmlTest.xml"));
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fillGrid();
}
}
protected void btImport_Click(object sender, EventArgs e)
{
string conn = ("Provider=Microsoft.Jet.OLEDB.4.0;" + ("Data Source=C:\\WebSqlEditor\\test.xls;" + "Extended Properties=Excel 8.0;"));
string SSQL = "SELECT name , dept, salary from [sheet1$]";
OleDbDataAdapter oleDA = new OleDbDataAdapter(SSQL, conn);
DataSet ds = new DataSet();
oleDA.TableMappings.Add("Table","ExcelTest");
oleDA.Fill(ds);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
thanks
Comment