none
I am new in c#, so please help me to solve this problem RRS feed

  • Question

  • I am trying to create a page using c#, i made a login page and registration page, after login i want to display the username and password on home page when the time of sign in , so i tried this method, but i am getting error like Error    1    Cannot convert method group 'ToString' to non-delegate type 'string'. Did you intend to invoke the method?   
     protected void Page_Load(object sender, EventArgs e)
        {
            String username = Session["user"].ToString();
            Label1.Text = "Welcome " + username;
            String sql = "SELECT * FROM registration WHERE username ='"+username+"'";
            connection c = new connection();
            SqlCommand cmd = new SqlCommand(sql,c.con);
            SqlDataReader reader= cmd.ExecuteReader();
            if (reader.Read())
            {
                String username1 =reader.GetValue(0).ToString;
                String password = reader.GetValue(1).ToString;
                TextBox1.Text = username1;
                TextBox2.Text = password;
            }
           
        }
    please help me
    Sunday, February 7, 2010 3:53 PM

Answers

  • You need to add () if you want to call a function that has no parameters.
    BTW, Your connection, command and reader needs to be disposed.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
    Visual C++ MVP
    Sunday, February 7, 2010 5:03 PM

All replies

  • You need to add () if you want to call a function that has no parameters.
    BTW, Your connection, command and reader needs to be disposed.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
    Visual C++ MVP
    Sunday, February 7, 2010 5:03 PM
  • Thank you sir i added () in function  String username1 =reader.GetValue(0).ToString();
                                                String password = reader.GetValue(1).ToString();
    now it is working... thanks a lot...
    Thursday, February 11, 2010 1:00 PM