我不确定我的代码有什么问题。当我运行它时,我收到错误:SqlException未被用户代码处理。 System.Data.dll中发生了'System.Data.SqlClient.SqlException'类型的异常,但未在用户代码中处理
其他信息:无效的对象名称'ProductionPlanFabric'。
这是什么意思?
谢谢:)
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();
}
答案 0 :(得分:0)
试试这段代码:
conn.Open();
daPPFabric.Fill(result);
DataView dvPPFabric = result.Tables[0].DefaultView;
conn.Close();