Results 1 to 3 of 3

Thread: advise about static in c#

  1. #1

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    advise about static in c#

    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: advise about static in c#

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Re: advise about static in c#

    pk thank u very much for the comment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width