int strReturnRowcount = 0;
        SqlConnection sqlConn = new SqlConnection(this.SqlDataSource1.ConnectionString);
        SqlCommand sqlComm = new SqlCommand("select * from z_dem where caption = '" + this.DropDownList1.SelectedValue + "' and userid = '" + this.TextBox1.Text + "' and pwd = '" + this.TextBox2.Text + "'", sqlConn);
        
        sqlConn.Open();
        strReturnRowcount = sqlComm.ExecuteNonQuery();
        this.TextBox4.Text = Convert.ToString(sqlComm.ExecuteNonQuery());
        sqlConn.Close();
        this.TextBox4.Text = "select * from z_dem where caption = '" + this.DropDownList1.SelectedValue + "' and userid = '" + this.TextBox1.Text + "' and pwd = '" + this.TextBox2.Text + "'";//Convert.ToString(strReturnRowcount);        if (strReturnRowcount == 0)
        {            this.TextBox3.Visible = true; 
        }
        else
        {            Response.Redirect("Default2.aspx");
        }我用的2005,可是每次执行strReturnRowcount的值都为-1,跳转到Default2.aspx,谁能帮我解决这个问题啊,第一次用2005啊

解决方案 »

  1.   

    建议你这样写看看
    将command里面的sql语句用变量提取出来比如string strSql="select * from z_dem where caption = '" + this.DropDownList1.SelectedValue + "' and userid = '" + this.TextBox1.Text + "' and pwd = '" + this.TextBox2.Text + "'";
     SqlCommand sqlComm = new SqlCommand(strSql,sqlConn);--这里下个断点,看strSql的值是多少!然后放到相应的sql执行器里面执行看看结果!
    预计是sql语句的错误