title: I want to show all Course Names According To Department It Shows Error "The data types text and nvarchar are incompatible in the equal to operator."
body: <p>I want to show all Course Names According To Department It Shows Error:</p>
  <blockquote>
  <p>The data types text  and nvarchar are incompatible in the equal to operator.</p>
  </blockquote>
  <p>Here Is My Code:</p>
  <pre class="lang-cs prettyprint-override"><code>    void GetCoursesNames()
      {
      SqlCommand cmd = new SqlCommand();
      conn.Open();
      cmd.Connection = conn;
      cmd.CommandText = &quot; select Course_Name from Course Where Department = @Department&quot;;
      //cmd.Parameters.AddWithValue(&quot;@Department&quot;, DepttextBox.Text);
      cmd.Parameters.AddWithValue(&quot;@Department&quot;, (object)DepttextBox.Text ?? DBNull.Value);
      SqlDataReader dr = cmd.ExecuteReader();
      while (dr.Read())
      {
      Subj_comboBox.Items.Add(dr[&quot;Course_Name&quot;]);
      }
      conn.Close();
  </code></pre>