sachin
sachin

Reputation: 21

Cannot implicitly convert type System.data.datatable to Microsoft.Office.Interop.Excel

 public DataTable populateVendorGridView()
        {

            DataSet ds = new DataSet();
            ds = (DataSet)Session["VendorInvoiceid"];

            return ds.Tables[0]; //getting error here
        }

Upvotes: 1

Views: 1901

Answers (1)

manji
manji

Reputation: 47968

a DataTable type exists in both namespaces:

Microsoft.Office.Interop.Excel

and

System.Data

which are imported into your file.

You have to explicitly reference the correct namespace for the return type of populateVendorGridView:

public System.Data.DataTable populateVendorGridView()
{
    ...

Upvotes: 4

Related Questions