初级问题
public int Login(string MobileNumber ,string Password)
{
try
{
System.Data.SqlClient.SqlDataReader dr;
SqlCommand cmd=new SqlCommand ();
cmd.CommandText ="Select ScrapID, Password,Status from p_scrap where mobilenumber='" + MobileNumber + "'";
cmd.Connection =DBConn.Connection;
dr=cmd.ExecuteReader ();
try
{
if (dr.Read())
{
if (!Convert.ToBoolean(dr["Status"]))
{
throw new UserAccountExpiredException("账户已注销,请激活账户!");
}
if (dr["Password"].ToString()==Password)
{
return Convert.ToInt32(dr["ScrapID"]);
}
}
else
throw new UserNotRegisterException("用户尚未注册");
}
catch(ApplicationException e)
{
throw e;
}
catch(Exception e)
{
throw new ApplicationException("系统错误:\n"+e.Message );
}
finally
{
dr.Close();
}
}
catch(SqlException e)
{
throw new ApplicationException("系统错误:\n"+e.Message );
}
catch(ApplicationException e)
{
throw e;
}
catch
{
throw new ApplicationException("系统错误!");
}
}
编译时说此方法没有返回值。我看不出该在哪里添加,请高手指教!