我的SQL语句如下
   datasource1.DataSet:=query1;
   sSql:= 'select * from sxbj where 1=1';
  if Edit1.Text <> '' then
    sSql := sSql + ' and cj = ' + QuotedStr(Edit1.Text);
  if Edit2.Text <> '' then
      sSql := sSql + ' and lx = ' + QuotedStr(Edit2.Text);
  if Edit3.Text <> '' then
      sSql := sSql + ' and xh = ' + QuotedStr(Edit3.Text);
  if Edit4.Text <> '' then
      sSql := sSql + ' and gb = ' + QuotedStr(Edit4.Text);
  if Edit5.Text <> '' then
      sSql := sSql + ' and hb = ' + QuotedStr(Edit5.Text);
  if Edit6.Text <> '' then
      sSql := sSql + ' and sszy = ' + QuotedStr(Edit6.Text);
  Query1.sql.Clear;
  Query1.SQL.Text := sSql;
  query1.ExecSQL;
  query1.Active:=true;
运行报datasource1,circular datalinks are not allowed.错,请大家解惑,谢谢

解决方案 »

  1.   

    从你上面写的代码来看没什么问题
    可能是datasource1或者query1设置错误
      

  2.   

    Open方法只能用来执行SQL语言的查询语句(Select命令),并返回一个查询结果集,
    而ExecSQL方法还可以用来执行其它常用的SQL语句(如Insert、UPDATE、 DELETE等命令)
    请你把你的程序后面的这句
    query1.ExecSQL;
    改成:
    query1.open;以后关于SQL语句的执行可以通用这个格式:
    query1.sql := "sql 语言";
    try
     query1.ExecSQL;
    except
     query1.open;
    end;
      

  3.   

    datasource1.DataSet:=query1;
       sSql:= 'select * from sxbj where 1=1';
     Query1.sql.Clear;
     Query1.SQL.Text := sSql;
     query1.ExecSQL;
      //注意这里不能这样使用了,要更新一次
     query1.close;
     query1.sql.text:='select * from sxbj';
     query1.Active:=true;
      

  4.   

    上面的代碼看不出錯誤來,絕對不是上面的代碼造成的。
    另外welliam(浪人wwl) 你的這種做法好嗎?如果sql語法錯誤你都找不到錯誤了,不知道sql到底運行了沒有。
    try
     query1.ExecSQL;
    except
     query1.open;
    end;
      

  5.   

    datasource1.DataSet:=query1;
       sSql:= 'select * from sxbj where 1=1';
      if Edit1.Text <> '' then
        sSql := sSql + ' and cj = ' + QuotedStr(Edit1.Text);
      if Edit2.Text <> '' then
          sSql := sSql + ' and lx = ' + QuotedStr(Edit2.Text);
      if Edit3.Text <> '' then
          sSql := sSql + ' and xh = ' + QuotedStr(Edit3.Text);
      if Edit4.Text <> '' then
          sSql := sSql + ' and gb = ' + QuotedStr(Edit4.Text);
      if Edit5.Text <> '' then
          sSql := sSql + ' and hb = ' + QuotedStr(Edit5.Text);
      if Edit6.Text <> '' then
          sSql := sSql + ' and sszy = ' + QuotedStr(Edit6.Text);
      Query1.sql.Clear;
      Query1.SQL.Text := sSql;
      query1.Active:=true;