{
protected void Page_Load(object sender, EventArgs e)
{
}
public string testing(int i)
{
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connString"]);
string sql = "SELECT COUNT[sellingcost] AS total FROM [Item]";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
cmd.CommandType = CommandType.Text;
da.Fill(ds, "Item");
dt = ds.Tables["Item"];
string category;
int total;
total = 100 / dt.Rows[0]["total"];
if (total * i <= 20)
category = "A";
else if (total * i <= 50)
category = "B";
else if (total * i <= 100)
category = "C";
return category;
}
}
当我run时,出现以下错误。
Error: Operator '/' cannot be applied to operands of type 'int' and 'object'
由于我一直不能解决这问题,所以才请问各位帮帮忙了,在此感激不尽!