title: Comparing a textbox input to a sql query
body: <p>Here is my code in c#, it is saying "No data exists for the row/column.", how can I improve this code to make it work properly?</p>
  
  <pre><code>db = new OleDbConnection();
  db.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + fileName;
  db.Open();
  
  string sql = "SELECT * FROM GroupNameNS WHERE GroupName = '" + Groupnametxt.Text.Trim() + "'";
  
  cmd = new OleDbCommand(sql, db);
  rdr = cmd.ExecuteReader();
  
  if (Groupnametxt.Text.Trim() == (string)rdr["GroupName"])
  {
    MessageBox.Show("Group Name taken, please try another name", "Error in Name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    membernumber1.ReadOnly = true;
  }
  else
  {
    sql = "INSERT INTO GroupNameNS VALUES ('" + Groupnametxt.Text.Trim() + "')";
    membernumber1.ReadOnly = false;
    cmd = new OleDbCommand(sql, db);
    rdr = cmd.ExecuteReader();
  }
  </code></pre>