Error 3 Cannot implicitly convert type 'string' to 'bool'

I am trying to setup a select statment to either select by data or not select by date if the user leaves the date fields blank.  I am using an if statment on the date field but keep getting the above error message.  Can someone tell me what I am missing.

Here is my code:
-------------------------------------------------------------------------

protected SqlDataAdapter CreateDRRAdapter()
        {

           
            SqlConnection conn = new SqlConnection(ConnString);
            SqlCommand cmd = new SqlCommand(SearchString, conn);

            tbName.Text = tbName.Text + "%";


            cmd.Parameters.Add(new SqlParameter("@DRR1", tbName.Text));
            cmd.Parameters.Add(new SqlParameter("@DOCUMENTID", tbDocumentId.Text));
            cmd.Parameters.Add(new SqlParameter("@USERNAME", tbDocCreatedBy.Text));
            cmd.Parameters.Add(new SqlParameter("@FROMDATE", datechooseFrom.Text));
            cmd.Parameters.Add(new SqlParameter("@TODATE", datechooserTo.Text));
         
            SqlDataAdapter sqlDA = new SqlDataAdapter(cmd);
            return sqlDA;
        }

        //------------   Search Tab
        private String ConnString
        {
            get
            {
                //ConnectionString comes from the Web.Config
                return ConfigurationManager.ConnectionStrings["213123ConnectionString"].ConnectionString;

            }
        }

        //------------   Search Tab
        private String SearchString
        {
            get
            {


                if (datechooseFrom.Text != "")
                {

                    String srchCmd = "SELECT DRRPHI.DOCUMENTID, DRRPHI.MODIFIEDDATE, DRRPHI.USERNAME, DRRPHI.DRR1 FROM DRRPHI WHERE DRRPHI.DOCUMENTID = @DOCUMENTID OR DRRPHI.MODIFIEDDATE >= @FROMDATE OR DRRPHI.MODIFIEDDATE <= @TODATE OR DRRPHI.DRR1 like @DRR1";
                    return srchCmd;
                }


                if (datechooseFrom.Text = "")   -----------------  Error occurs here and not on the above IF statment.
                {

                    String srchCmd = "SELECT DRRPHI.DOCUMENTID, DRRPHI.MODIFIEDDATE, DRRPHI.USERNAME, DRRPHI.DRR1 FROM DRRPHI WHERE DRRPHI.DOCUMENTID = @DOCUMENTID OR DRRPHI.DRR1 like @DRR1";
                    return srchCmd;
                }



            }
        }
kwh3856Asked:
Who is Participating?
 
tiagosalgadoConnect With a Mentor Commented:
In C# to compare any type of variable you need to use "==" instead of "=". So, your if need to be like "if (datechooseFrom.Text == "") ".
0
 
kwh3856Author Commented:
Thank you.  I always forget that.

Thanks
Kenny
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.