语法错误:WHERE运算符后缺少操作数 [英] Syntax Error: Missing operand after WHERE operator

查看:889
本文介绍了语法错误:WHERE运算符后缺少操作数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  private   void  toolStripButton3_Click_1( object  sender,EventArgs e)
{
try
{
Search(toolStripTextBox1。文本);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public DataTable Search( string value
{
DataTable table = new DataTable();
table =(DataTable)dataGridView1.DataSource;
字符串 Param = SELECT * FROM + table + WHERE Firstname = + value;
table.Select(Param);
return 表;

}



我试图在数据表中搜索名字

我得到一个错误,说错过了操作数之后的地方运营商

请帮帮我

还有其他办法吗

谢谢

解决方案

您需要在value变量周围添加''''。它应该是:



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


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

解决方案

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

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


这篇关于语法错误:WHERE运算符后缺少操作数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆