title: multiple Parameters - Syntax error in string in query expression: VS 2010 with MS-Access 2003
body: <p>I am receiving</p>
  
  <blockquote>
    <p>OleDBException was unhandled  error of "Syntax error (missing operator) in query<br>
      expression '(StudentID = 100' OR StudentName = 'Nick' OR StudentCNCI = '78894452)Bob'."</p>
  </blockquote>
  
  <pre><code>    private void btnFind_Click(object sender, EventArgs e)
      {
  
          string title = textBox1.Text.ToString();
          string queryString = "SELECT * FROM Students WHERE (StudentID = " + StudIDTb.Text.ToString() + "' OR StudentName = '" + StudNameTb.Text.ToString() + "' OR StudentCNCI = '" + StudCNCITb.Text.ToString() + ")" + title;
  
          OleDbCommand command = new OleDbCommand();
          command.CommandText = queryString;
  
          command.Connection = myCon;
          myCon.Open();
  
          OleDbDataReader dr = command.ExecuteReader(); // error pointing here
          while (dr.Read())
          {
              StudIDTb.Text += String.Format("StudentID: {0}\n", dr["StudentID"].ToString());
              StudNameTb.Text += String.Format("StudentName: {0}\n", dr["StudentName"].ToString());
              StudCNCITb.Text += String.Format("StudentCNIC: {0}\n", dr["StudentCNIC"].ToString());
              StudDOBTb.Text += String.Format("StudentDOB: {0}\n", dr["StudentDOB"].ToString());
          }
          myCon.Close();
  
       }
  </code></pre>
  
  <p>I have also tried...</p>
  
  <pre><code>string queryString = "SELECT * FROM Students WHERE (StudentID = " + StudIDTb.Text + "' OR StudentName = '" + StudNameTb.Text + "' OR StudentCNCI = '" + StudCNCITb.Text + ")" + title;
  </code></pre>
  
  <p>I don't want to give you wrong impression I am "lazy" but I am assuming I am getting this error because I have query it incorrectly or I have made a typo error or could it be something else. Please can someone help me, thanks in advance. </p>
  
  <p>ps I know I am getting criticism for not using parameterized queries. I will change it once I got the basic right. I know a lot of similar questions have been asked here but I still can't get it right.   </p>
  
  <p><strong>UPDATE 1</strong>
  I have changed it to </p>
  
  <pre><code>"SELECT * FROM Students WHERE StudentID = " + StudIDTb.Text + " OR StudentName = '" + StudNameTb.Text + "', OR StudentCNCI = '" + StudCNCITb.Text + ")";
  </code></pre>
  
  <p>I am now receiving error of...</p>
  
  <blockquote>
    <p>Syntax error (comma) in query expression </p>
  </blockquote>
  
  <p>I am looking into it</p>
  
  <p><strong>Update 2</strong></p>
  
  <pre><code>string queryString = "SELECT * FROM Students WHERE StudentID = " + StudIDTb.Text + "' OR StudentName = '" + StudNameTb.Text + "' OR StudentCNCI = '" + StudCNCITb.Text + "'";
  </code></pre>
  
  <p>Receiving the same error.</p>
  
  <p>Looking into it</p>
  
  <p><strong>Update 3</strong>
  If it can't be solved I do it the way it should be, using parameterized queries as highly recommended if it means to solve the problem and probably easy to spot any problems with the code </p>