简体   繁体   English

未处理SQLException

[英]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. 当我运行它时,出现错误:用户代码未处理SqlException。 An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code System.Data.dll中发生类型'System.Data.SqlClient.SqlException'的异常,但未在用户代码中处理

Additional information: Invalid object name 'ProductionPlanFabric'. 附加信息:无效的对象名称'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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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