Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
private void toolStripButton3_Click_1(object sender, EventArgs e)
        {
            try
            {
                Search(toolStripTextBox1.Text);
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public DataTable Search(string value)
        {
            DataTable table = new DataTable();
            table = (DataTable)dataGridView1.DataSource;
            String Param = "SELECT * FROM " + table +" WHERE Firstname = "+value;
            table.Select(Param);
            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
Edited 9-Jan-13 10:12am
v2
Comments
jibesh at 9-Jan-13 15:27pm
   
from where you are getting the tableName?

1 solution

Rate this: bad
good
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 + "';";
  Permalink  

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

  Print Answers RSS
0 CPallini 385
1 BillWoodruff 334
2 Sergey Alexandrovich Kryukov 333
3 George Jonsson 285
4 OriginalGriff 267
0 OriginalGriff 5,095
1 CPallini 4,285
2 Sergey Alexandrovich Kryukov 3,767
3 George Jonsson 2,941
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2014
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