我要以作者(Author)、日期(EnterDate)、关键字(KeyWord)进行模糊查询,日期是from  to 形式的,我写的查询语句连接起来是这样的:
select * from CFKLOCATE002 where Author like '%' EnterDate in ( 1982/01/01 0:00:00,2007/02/01 8:55:16 ) KeyWord like '%abap%' 
系统报错,应该怎么写?谢谢了

解决方案 »

  1.   

    加 and
    我觉得写这种东西,写到数据库里自己查查看报什么错,再编译比较好点
      

  2.   

    还是有错,报的是这个错:
    クエリ式 'Author like '%' and EnterDate in ( 1982/01/01 0:00:00,2007/02/01 9:15:31 ) and KeyWord like '%abap%'' の 構文エラー : 演算子がありません。
      

  3.   

    你是能过什么方式来执行查询的?因为你只给出了你拼出的SQL,所以没办法判断,能说详细点吗
      

  4.   

    Author like '%',给个参数喃?Author like '%a'
      

  5.   

    我是这么写的, 
    //作者
            string zuozhe;
            if (this.TextBox2.Text.ToString()  == string.Empty )
                zuozhe = "%";
            else
                zuozhe = this.TextBox2.Text;        //日期
            DateTime  datefrom,dateto;
            if (this.TextBox3.Text == string.Empty && this.TextBox4.Text != string.Empty)
            {
                datefrom = DateTime .Parse ("1982/01/01 00:00:00");
                dateto = Convert.ToDateTime(this.TextBox3.Text);
            }
            else if (this.TextBox3.Text != string.Empty && this.TextBox4.Text == string.Empty)
            {
                datefrom = Convert.ToDateTime(this.TextBox3.Text);
                dateto = DateTime.Now;
            }
            else if (this.TextBox3.Text != string.Empty && this.TextBox4.Text != string.Empty)
            {
                datefrom = Convert.ToDateTime(this.TextBox3.Text);
                dateto = Convert.ToDateTime(this.TextBox4.Text);
            }
            else  
            {
                datefrom = DateTime.Parse("1982/01/01 00:00:00");
                DateTime dt = DateTime.Now;
                string str4 = Convert.ToString(dt);
                dateto = DateTime.Parse (str4);
            }        //关键字        string keyword;
            if (this.TextBox6.Text == string.Empty)
                keyword = "%";
            else
                keyword = "%" + this.TextBox6.Text +"%";        string str1 = "Author like '"+zuozhe+"' and ";
            string str2 = "EnterDate in ( " + datefrom + "," + dateto + " )"+" and ";
            string str3 = "KeyWord like '"+keyword+"' ";
            olecmd = olecmd + str1 + str2 + str3;
            conn.Open();
            adapter = new OleDbDataAdapter(olecmd, conn);
            adapter.Fill(dsTable, "filelocate");
            dtTable = dsTable.Tables["filelocate"];
            conn.Close();
    报错。
      

  6.   

    1、就像大家说的那样,Keyword前少拼了一个and
    2、你的两个datetime少了单号,而且你的原意是FROM TO,所以用
    >= FromDatetime and <= ToDatetime的形式才对吧