Click here to Skip to main content
13,548,896 members
Rate this:
Please Sign up or sign in to vote.
See more:
private void toolStripButton3_Click_1(object sender, EventArgs e)
            catch(Exception ex)
        public DataTable Search(string value)
            DataTable table = new DataTable();
            table = (DataTable)dataGridView1.DataSource;
            String Param = "SELECT * FROM " + table +" WHERE Firstname = "+value;
            return table;

Im trying to search the datatable for a firstname
I Get an error saying Missing Operand after where operator
Please Help me
Is there another way to do it
thank you
Posted 9-Jan-13 9:15am
Updated 9-Jan-13 10:12am
Jibesh 9-Jan-13 15:27pm
from where you are getting the tableName?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to add '' around your "value" variable. It should read:

String Param = "SELECT * FROM " + table + " WHERE Firstname = '" + value + "';";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180515.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100