asp.net 一个函数里定义的变量怎么在另一个函数中应用?怎么输出?
publicstaticfloatRule(stringindex_name,stringrule){SqlConnectionconn=newSqlConnection...
public static float Rule(string index_name, string rule)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
string sel = "select * from " + rule + " where 指标='" + index_name + "'";
SqlCommand com = new SqlCommand(sel, conn);
SqlDataReader sdr = com.ExecuteReader();
sdr.Read();
float weight = Convert.ToSingle(sdr["权重"].ToString());
float gramax= Convert.ToSingle(sdr["最高分数"].ToString());
sdr.Close();
conn.Close();
return weight;
}
public void Caculate()
{
?? if(garmax <100)提示上下文不存在garmax
{
}
}
?? Label1.Text = "最高分数为:" + Rule("压力", " Value").ToString(); 展开
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
string sel = "select * from " + rule + " where 指标='" + index_name + "'";
SqlCommand com = new SqlCommand(sel, conn);
SqlDataReader sdr = com.ExecuteReader();
sdr.Read();
float weight = Convert.ToSingle(sdr["权重"].ToString());
float gramax= Convert.ToSingle(sdr["最高分数"].ToString());
sdr.Close();
conn.Close();
return weight;
}
public void Caculate()
{
?? if(garmax <100)提示上下文不存在garmax
{
}
}
?? Label1.Text = "最高分数为:" + Rule("压力", " Value").ToString(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询