sql.Add('select tcustomer.cust_no,tcustomer.cust_name,tcustomer.cust_bp,tcustomer.bp_code,tcustomer.bp_type,tcustomer.reg_date,tcustomer.unreg_date,tcustomer.mobile,tcustomer.email from tgp_cust,tcustomer where tgp_cust.group_no='+quotedstr(copy((node.Text),1,2)) and tgp_cust.cust_no=tcustomer.cust_no);
不知是错在那里,就是到最后的tgp_cust.cust_no时就通不过了,是不是要满足双重条件的连接词,and用错了。急,在线急盼高人指点。

解决方案 »

  1.   

    sql.Add('select tcustomer.cust_no,tcustomer.cust_name,tcustomer.cust_bp,tcustomer.bp_code,tcustomer.bp_type,tcustomer.reg_date,tcustomer.unreg_date,tcustomer.mobile,tcustomer.email from tgp_cust,tcustomer where tgp_cust.group_no='+quotedstr(copy((node.Text),1,2))+' and tgp_cust.cust_no=tcustomer.cust_no');后面是不是少了两个单引号?
      

  2.   

    应该是这样吧:
    sql.Add('select tcustomer.cust_no,tcustomer.cust_name,tcustomer.cust_bp,tcustomer.bp_code,tcustomer.bp_type,tcustomer.reg_date,tcustomer.unreg_date,tcustomer.mobile,tcustomer.email from tgp_cust,tcustomer where tgp_cust.group_no='''+quotedstr(copy((node.Text),1,2))+'''  and tgp_cust.cust_no='''+tcustomer.cust_no+'''');
      

  3.   

    没有少,auotedstr函数即是一个定义字符两边单引号的函数,请高手出来指点一下,问题应在语法结构上,即双重条件上
      

  4.   

    去掉and后面部份的话是可以的。
      

  5.   

    嗯,前面写错了,应该是这样sql.Add('select tcustomer.cust_no,tcustomer.cust_name,tcustomer.cust_bp,tcustomer.bp_code,tcustomer.bp_type,tcustomer.reg_date,tcustomer.unreg_date,tcustomer.mobile,tcustomer.email from tgp_cust,tcustomer where tgp_cust.group_no='''+quotedstr(copy((node.Text),1,2))+''' and tgp_cust.cust_no=tcustomer.cust_no');
      

  6.   

    sql.Add('select tcustomer.cust_no,tcustomer.cust_name,tcustomer.cust_bp,tcustomer.bp_code,tcustomer.bp_type,tcustomer.reg_date,tcustomer.unreg_date,tcustomer.mobile,tcustomer.email from tgp_cust,tcustomer where tgp_cust.group_no='+quotedstr(copy((node.Text),1,2)) +' and  tgp_cust.cust_no=tcustomer.cust_no');
    应该是这样的吧  +' and  tgp_cust.cust_no=tcustomer.cust_no'
      

  7.   

    sql.Add('select 
    tcustomer.cust_no,tcustomer.cust_name,tcustomer.cust_bp,tcustomer.bp_code,tcustomer.bp_type,tcustomer.reg_date,tcustomer.unreg_date,tcustomer.mobile,tcustomer.email from tgp_cust,tcustomer where tgp_cust.group_no='+''''+quotedstr(copy((node.Text),1,2))+''''+and tgp_cust.cust_no=tcustomer.cust_no');
      

  8.   

    +quotedstr(copy((node.Text),1,2)) +'and tgp_cust.cust_no=tcustomer.cust_no)';
      

  9.   

    +quotedstr(copy((node.Text),1,2)) +' and tgp_cust.cust_no=tcustomer.cust_no)';
      

  10.   

    sql.Add('select tcustomer.cust_no,tcustomer.cust_name,tcustomer.cust_bp,tcustomer.bp_code,tcustomer.bp_type,tcustomer.reg_date,tcustomer.unreg_date,tcustomer.mobile,tcustomer.email from tgp_cust,tcustomer where tgp_cust.group_no='+quotedstr(copy((node.Text),1,2)) +'and tgp_cust.cust_no=tcustomer.cust_no');
      

  11.   

    sql.Add('select tcustomer.cust_no,tcustomer.cust_name,tcustomer.cust_bp,tcustomer.bp_code,tcustomer.bp_type,tcustomer.reg_date,tcustomer.unreg_date,tcustomer.mobile,tcustomer.email from tgp_cust,tcustomer where tgp_cust.group_no='+quotedstr(copy((node.Text),1,2)) +'and tgp_cust.cust_no=tcustomer.cust_no');
      

  12.   

    sql.Add('select tcustomer.cust_no,tcustomer.cust_name,tcustomer.cust_bp,tcustomer.bp_code,tcustomer.bp_type,tcustomer.reg_date,tcustomer.unreg_date,tcustomer.mobile,tcustomer.email from tgp_cust,tcustomer where tgp_cust.group_no="'+quotedstr(copy((node.Text),1,2))+'"'+' and tgp_cust.cust_no=tcustomer.cust_no');
    这样应该是对的了
      

  13.   

    试试这个:
    sql.text :=
    'select t1.cust_no,t1.cust_name,t1.cust_bp,t1.bp_code,t1.bp_type,t1.reg_date,t1.unreg_date,t1.mobile,t1.email from tgp_cust as t2,tcustomer as t1 where t2.group_no='''+quotedstr(copy((node.Text),1,2))+'''  and t2.cust_no=t1.cust_no';另外,建议 多使用tgp_cust as t2,tcustomer as t1  
    使用t1,t2之后,可以让代码变得更加简洁。
      

  14.   

    注意,
    1。可以直接copy中间的内容直接使用。
    2。'''  是,3个半角单引号
      

  15.   

    你用的是MS SQL Server 2000么?如果是,可以用事件查探器跟踪一下传进来的SQL语句,就可以很直观地知道什么地方写错了。