Error occur in CSharp

Sep 2 2011 2:12 AM
hello everyone;

i am writing a code . in the colored area ,there are exception occur .the exception are :

The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.

protected void Button_login_Click(object sender, EventArgs e)
        {
            object obj = null;
            SqlConnection mycon = new SqlConnection();
            mycon=connection.get();
            //mycon = connection.get();
            Session["username"] = TextBox_user_name.Text;
            Session["password"] = TextBox_password.Text;
            string s = "select count(*) from login where user_name='" + Session["username"] + "' and password ='" + Session["password"] + "'";
            SqlCommand cmd = new SqlCommand(s, mycon);
            obj = cmd.ExecuteScalar();
            if (Convert.ToInt32(obj) != 0)
            {
                Label_display_user_name.Text = "WELLCOME :: " + Session["user_name"];
            }
            else
            {
                Label_result.Text = "invalid user name and password";
            }
       
       
        }


regards
sumaira

Answers (6)