views:

13

answers:

1

I use it in C#,but when i set the source there's a error. Codes:

  string strConn = "Provider=Microsoft.Jet.OleDb.4.0;" + "data source=" + filename + ";Extended Properties='Excel 8.0; HDR=YES; IMEX=1'";
        OleDbConnection conn = new OleDbConnection(strConn);
        conn.Open();
        DataSet ds = new DataSet();
        OleDbDataAdapter odda = new OleDbDataAdapter("select * from [电子订单$]", conn);
        odda.Fill(ds, "table");
        axSpreadsheet1.DataSource = ds.Tables[0];

error:can not cast “System.Data.DataTable”to“msdatasrc.DataSource”。 then i modify the code:axSpreadsheet1.DataSource = ds.Tables[0]; to axSpreadsheet1.DataSource = (msdatasrc.DataSource)ds.Tables[0]; there alsow has the error what can i do?

A: 

One obvious solution is to examine what is msdatasrc.DataSource. Create a new instance of it and than copy over the table rows to it, row by row or by using some other tool.

veljkoz