PDA

Click to See Complete Forum and Search --> : advise about static in c#


popskie
Aug 2nd, 2005, 09:25 PM
pls take a look the class below. I just want to ask some advise from anyone
about this class if it is good or have some other way to do this.

pls give me advice.

public class SelectTable
{
public static SqlDataReader loginuser(string par1)
{
SqlCommand cmd =new SqlCommand();
cmd.Connection =stsqcon.getConnection();
cmd.CommandText = "Select top 1 * From users where login =@login";
cmd.Parameters.Add("@login",SqlDbType.NChar ,10);
cmd.Parameters["@login"].Value =par1;
cmd.CommandType = CommandType.Text;
SqlDataReader dreader = cmd.ExecuteReader(CommandBehavior.SingleResult);
return dreader;
}
}



popskie

jmcilhinney
Aug 3rd, 2005, 01:04 AM
Without seeing what else the class contains I couldn't say for sure but it seems inappropriate to me. I wouldn't expect a function called LoginUser to return an SqlDataReader. I would expect it to return a bool indicating whether the login was successful or not. I would think that this would be a method of your login form rather than some specific class, although I don't know what else the class contains. I also think SelectTable seems like an odd class name.

popskie
Aug 3rd, 2005, 02:14 AM
pk thank u very much for the comment.