我用delphi编写一个程序用于操作sql库,在读取sql库内数据时没出现问题,但是在delphi里用sql语句对sql库中的表进行update,insert操作都不成功,并且都不报错,并且sql语句写法也没错.请问高手这是怎么回事?为什么库只能读出,不能写入和修改呢?是不是我的库的哪个参数或者是表的哪个哪个参数有问题呀?求救! 谢谢!
解决方案 »
- 如何判断一个元素是否存在于动态数组中
- 用java开发的webservices,返回值是jdom的Element类型,用delphi如何调用? java的参数类型已经确定就是Jdom,不是String类型,在delphi中
- [求助]ACTIVEFORM的问题,退格,方向,回车失效
- fengxue291080(★爱有多深★) 给我进来
- 一个不是很复杂的报表问题,用过fastreport的都来看看
- 请教,哪位大虾用过cxgrid,如何提出多选的数据,是包含再DevExpress那一套控件里的(我都发了2遍啊..没人理我555)
- 为什么要使用面向对象的方法?(why use OO methodology?)
- 关于MSN Messager的编程。。。
- ACCESS与OLE
- 如何用UDP在局域网广播
- 大家试一下这个问题,不知是不是delphi6的bug
- 用API函数 怎样让指定的程序只运行一个?
如果不是,
你把代码贴出来看看
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 //¸Ä±äÒ»Ïî ¼ÓÈëÒ»Ïî
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 //¸Ä±äÒ»Ïî ¼ÓÈëÒ»Ïî
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 //¸Ä±äÁ½Ïî
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('´æ´¢Íê³É£¡');
end;
ExecSQL呀?