用ADOQuery1.ExecSQL 执行sql语句
例如:insert into dd_std_code
(std_type_id,std_code_id1,std_code_name,std_code_re)
values(3,'111','aaa','')showmessage 中显示的是如上所述的语句
但是在数据库中执行的是values(4,'111','aaa#','')
也就是将int型数据自增了 晕呀!!!
谢谢指导
例如:insert into dd_std_code
(std_type_id,std_code_id1,std_code_name,std_code_re)
values(3,'111','aaa','')showmessage 中显示的是如上所述的语句
但是在数据库中执行的是values(4,'111','aaa#','')
也就是将int型数据自增了 晕呀!!!
谢谢指导
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Update dd_std_code');
ADOQuery1.SQL.Add('set std_code_id1=' + format('%s',[quotedStr(Trim(self.CodeGrid.Cells[0,i]))]));
ADOQuery1.SQL.Add(', std_code_name=' +format('%s',[quotedStr(Trim(self.CodeGrid.Cells[1,i]))]));
ADOQuery1.SQL.Add(', std_code_re=' +format('%s',[quotedStr(Trim(self.CodeGrid.Cells[2,i]))]));
ADOQuery1.SQL.Add('where std_type_id= ' + Trim(self.CodeGrid.Cells[4,i])) ;
ADOQuery1.SQL.Add('and std_code_id= ' + Trim(self.CodeGrid.Cells[3,i])) ; showmessage(self.ADOQuery1.SQL.Text ); self.ADOQuery1.ExecSQL ;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Update dd_std_code');
ADOQuery1.SQL.Add('set std_code_id1=' + format('%s',[quotedStr(Trim(self.CodeGrid.Cells[0,i]))]));
ADOQuery1.SQL.Add(', std_code_name=' +format('%s',[quotedStr(Trim(self.CodeGrid.Cells[1,i]))]));
ADOQuery1.SQL.Add(', std_code_re=' +format('%s',[quotedStr(Trim(self.CodeGrid.Cells[2,i]))]));
ADOQuery1.SQL.Add('where std_type_id= ' + Trim(self.CodeGrid.Cells[4,i])) ;
ADOQuery1.SQL.Add('and std_code_id= ' + Trim(self.CodeGrid.Cells[3,i])) ; showmessage(self.ADOQuery1.SQL.Text ); self.ADOQuery1.ExecSQL ;
只要是sql中出现int型数据都是自增1我在sql中用''就可以正常了
why?
表中 有自增字段 但是不是我用的
这个问题加 ''虽然解决了但是还是不知道为什么呀 !!!