我用delphi编写一个程序用于操作sql库,在读取sql库内数据时没出现问题,但是在delphi里用sql语句对sql库中的表进行update,insert操作都不成功,并且都不报错,并且sql语句写法也没错.请问高手这是怎么回事?为什么库只能读出,不能写入和修改呢?是不是我的库的哪个参数或者是表的哪个哪个参数有问题呀?求救! 谢谢!

解决方案 »

  1.   

    可能是你SQL数据库的权限问题。
    如果不是,
    你把代码贴出来看看
      

  2.   

    show us your code and hava a look!
      

  3.   

    我的源代码如下:(代码是长了一点,不过编译和运行都没出现过任何问题,但是就是insert和update命令不起作用,但是select命令没问题,adoquery1.FieldByName('pro').asstring等经过设置断点发现也没问题,最后我觉得是哪里设置的问题,请各位务必帮帮忙,感激不尽呀!)
       procedure TForm1.BitBtn1Click(Sender: TObject);
    var
     j,l,m:integer;
     str:string;
    begin
     j:=0;
     l:=0;
     edit1.Text:=combobox1.Text;
     edit2.Text:=combobox2.Text;
     if (edit1.Text='') or   (edit2.Text='') then
      begin
       showmessage('ûÊäÈëÆðʼ¼°ÖÕÖ¹ÐźŷÖ×Ó£¡');
       exit;
      end;
     edit1.Text:=edit1.Text+StringOfChar(' ',20-length(edit1.Text));
     edit2.Text:=edit2.Text+StringOfChar(' ',20-length(edit2.Text));
     adoquery6.Close;
     adoquery6.SQL.Clear;
     adoquery6.sql.add('select pro from propre');
     adoquery6.open;
     adoquery6.first;
     adoquery1.Close;
     adoquery1.SQL.Clear;
     adoquery1.sql.add('select pro from propre');
     adoquery1.open;
     adoquery1.first;
     While not adoquery1.Eof do
     begin
       if adoquery1.FieldByName('pro').asstring=edit1.Text then
          j:=j+1;
          adoquery1.next;
     end;
     While not adoquery6.Eof do
     begin
       if adoquery6.FieldByName('pro').asstring=edit2.Text  then
          l:=l+1;
          adoquery6.next;
     end;
     if (j=0) and (l=0) then //мÓÈëÁ½Ïî
      begin
        adoquery2.Close;
        adoquery2.sql.Clear;
        adoquery2.sql.add('insert propos(pro,pos1) values '+ format('(''%s",''%s'')',[edit1.text,edit2.text]));
        adoquery3.Close;
        adoquery3.sql.Clear;
        adoquery3.sql.add('insert propre(pro) values '+ format('(''%s'')',[edit1.text]));
        adoquery4.Close;
        adoquery4.sql.Clear;
        adoquery4.sql.add('insert propre(pro,pre1) values '+ format('(''%s'',''%s'')',[edit2.text,edit1.text]));
        adoquery5.Close;
        adoquery5.sql.Clear;
        adoquery5.sql.add('insert propos(pro) values '+ format('(''%s'')',[edit2.text]));
      end; if (j=0) and (l<>0) then  //&cedil;&Auml;±&auml;&Ograve;&raquo;&Iuml;&icirc; &frac14;&Oacute;&Egrave;&euml;&Ograve;&raquo;&Iuml;&icirc;
      begin
        adoquery2.Close;
        adoquery2.sql.Clear;
        adoquery2.sql.add('insert propos(pro,pos1) values '+ format('(''%s",''%s'')',[edit1.text,edit2.text]));
        adoquery3.Close;
        adoquery3.sql.Clear;
        adoquery3.sql.add('insert propre(pro) values '+ format('(''%s'')',[edit1.text]));    adoquery4.Close;
        adoquery4.SQL.Clear;
        adoquery4.SQL.Add('select * from propre where pro='+''''+Edit2.Text+'''');
        adoquery4.Open;
        adoquery4.First;
        for m:=1 to 50 do
        begin
         str:='pre'+inttostr(m);
         if adoquery4.FieldByName(str).asstring='' then
          begin
            adoquery4.SQL.Add('update propre set '''+str+'''='+''''+Edit1.Text+''' where  pro='+''''+Edit2.Text+'''');
            break;
          end;
        end;
      end; if (j<>0) and (l=0) then //&cedil;&Auml;±&auml;&Ograve;&raquo;&Iuml;&icirc; &frac14;&Oacute;&Egrave;&euml;&Ograve;&raquo;&Iuml;&icirc;
      begin
        adoquery4.Close;
        adoquery4.sql.Clear;
        adoquery4.sql.add('insert propre(pro,pre1) values '+ format('(''%s'',''%s'')',[edit2.text,edit1.text]));
        adoquery5.Close;
        adoquery5.sql.Clear;
        adoquery5.sql.add('insert propos(pro) values '+ format('(''%s'')',[edit2.text]));    adoquery3.Close;
        adoquery3.SQL.Clear;
        adoquery3.SQL.Add('select * from propos where pro='+''''+Edit1.Text+'''');
        adoquery3.Open;
        adoquery3.First;
        for m:=1 to 50 do
        begin
         str:='pos'+inttostr(m);
         if adoquery3.FieldByName(str).asstring='' then
          begin
            adoquery3.SQL.Add('update propos set '''+str+'''='+''''+Edit2.Text+''' where  pro='+''''+Edit1.Text+'''');
            break;
          end;
        end;
      end; if (j<>0) and (l<>0) then //&cedil;&Auml;±&auml;&Aacute;&frac12;&Iuml;&icirc;
      begin
        adoquery4.Close;
        adoquery4.SQL.Clear;
        adoquery4.SQL.Add('select * from propre where pro='+''''+Edit2.Text+'''');
        adoquery4.Open;
        adoquery4.First;
        for m:=1 to 50 do
        begin
         str:='pre'+inttostr(m);
         if adoquery4.FieldByName(str).asstring='' then
          begin
            adoquery4.SQL.Add('update propre set '''+str+'''='+''''+Edit1.Text+''' where  pro='+''''+Edit2.Text+'''');
            break;
          end;
        end;
        adoquery3.Close;
        adoquery3.SQL.Clear;
        adoquery3.SQL.Add('select * from propos where pro='+''''+Edit1.Text+'''');
        adoquery3.Open;
        adoquery3.First;
        for m:=1 to 50 do
        begin
         str:='pos'+inttostr(m);
         if adoquery3.FieldByName(str).asstring='' then
          begin
            adoquery3.SQL.Add('update propos set '''+str+'''='+''''+Edit2.Text+''' where  pro='+''''+Edit1.Text+'''');
            break;
          end;
        end;
      end;
      showmessage('&acute;&aelig;&acute;&cent;&Iacute;ê&sup3;&Eacute;&pound;&iexcl;');
    end;
      

  4.   

    但是我没有看到你的CODE中有执行Update,Insert 语句的代码:
    ExecSQL呀?
      

  5.   

    你在Inset、Upate时用参数传递试试
      

  6.   

    最好调用存储过程,如果在客户端做不止是不是应该加上updatebatch(arall)