我让它为1个标签工作但是当我尝试为其他标签添加相同的代码时我不能使用“GetNumber”和“noRows”
//
//Populate the OrderID label
sqlSupplierOrder = @"select * from SupplierOrder";
daSupplierOrder = new SqlDataAdapter(sqlSupplierOrder, cnstr);
cmdBSupplierOrder = new SqlCommandBuilder(daSupplierOrder);
daSupplierOrder.FillSchema(dsPennyburnGreg, SchemaType.Source, "SupplierOrder");
daSupplierOrder.Fill(dsPennyburnGreg, "SupplierOrder");
int noRows = dsPennyburnGreg.Tables["SupplierOrder"].Rows.Count;
if (noRows == 0)
lbl_OrderID.Text = "7000";
else
{
GetNumber(noRows);
}
int noRows = dsPennyburnGreg.Tables["Payment"].Rows.Count;
if (noRows == 0)
lbl_PaymentRef.Text = "8000";
else
{
GetNumber(noRows);
}
}
答案 0 :(得分:0)
您已经两次声明noRows
。从第二个声明前面删除int
,以便重用该变量。
为什么不像GetNumber
声明一样使用Rows.Count
,而不是使用if
?