返回值为对象,调用对象的值为什么和预期的不对
帮帮忙各位大虾们,我在类中定义了一个函数
public static AAcademe Find_Zys(string username)
{
string SqlConnStr = "";
AAcademe aca = new AAcademe();
SqlConnStr = AAcademe.Link_Sql_Aca();
string mysql = "select * from TStudent where login= '" + username + "'";
SqlConnection myconnection = new SqlConnection(SqlConnStr);
SqlCommand mycommand = new SqlCommand(mysql, myconnection);
myconnection.Open();
SqlDataReader sqlreader = mycommand.ExecuteReader();
while (sqlreader.Read())
{
aca.id = int.Parse(sqlreader["id"].ToString());
aca.academe = sqlreader["academe"].ToString();
aca.login = sqlreader["login"].ToString();
aca.pwd = sqlreader["pwd"].ToString();
aca.num = int.Parse(sqlreader["num"].ToString());
aca.peoplemax = int.Parse(sqlreader["peoplemax"].ToString());
}
myconnection.Close();
return aca;
}
想在后台调用这个函数,取得返回的对象的相应值,为什么显示的值为0
后台函数:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
userName = Request["username"].ToString().Trim();
style1 = Request["style1"].ToString().Trim();
AAcademe aca = new AAcademe();
aca = AAcademe.Find_Zys(userName);
nZys.Text = aca.num.ToString().Trim();
nTrs.Text = aca.peoplemax.ToString().Trim();
}
else
{
}
}
高手帮帮忙啊,毕业设计纠结啊。。。。期待您的回答,谢谢!
------解决方案--------------------
断点调试下!