简体   繁体   中英

SQLException unhandled

I'm not sure whats wrong with my codes. When I run it, I get the error: SqlException was unhandled by user code. An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code

Additional information: Invalid object name 'ProductionPlanFabric'.

What does this mean?

Thank you :)

    private void displayPendingFabric()
    {
        string strConn = ConfigurationManager.ConnectionStrings
                         ["ZZFashionIMSConnectionString"].ToString();
        SqlConnection conn = new SqlConnection(strConn);

        SqlCommand cmd = new SqlCommand("SELECT ProductionPlanID, FashionStyleID, FabricID, WarehouseID, PPStatus, PPFabricReqd, PPFabricIssued FROM ProductionPlanFabric WHERE PPStatus = 0 OR PPStatus = 2", conn);

        SqlDataAdapter daPPFabric = new SqlDataAdapter(cmd);
        DataSet result = new DataSet();

        conn.Open();
        daPPFabric.Fill(result, "ProductionPlanFabric");
        DataView dvPPFabric = result.Tables["ProductionPlanFabric"].DefaultView; 
        conn.Close();

        gvPPFabric.DataSource = dvPPFabric;
        gvPPFabric.DataBind();

    }

Try this code:

conn.Open();
daPPFabric.Fill(result);
DataView dvPPFabric = result.Tables[0].DefaultView; 
conn.Close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM