我想你的id字段是属于自动增加(autoincreasement)的吧,在这种情况下,你可以控制记录转移的过程中不对临时表的id字段记行赋值即可。
解决方案 »
- 【求思路】多个任务需要定时检测,怎么让开销最省?
- 大家的ICO图标是哪儿找的?
- 请有线程编程经验的cc们进来看看
- 1,Delphi中添加Agent控件对应那个包!2,还有一些控件控件对应那些包?各40和60
- Microsoft.Jet.OLEDB.3.5升级成4.0?请高手指教!
- comcat.h对应Delphi里边的哪个dcu或是pas?
- 请教:QReport可不可以任意比例缩放报表? 哪位大虾告诉我怎么做?谢谢啦
- 屏保安装问题
- 第四次问ado问题,很急,星期一要交,谁能帮个忙呀
- 想学习TTS,哪有文档/教材/源码等
- 怎么用程序实现拷贝文件?
- 怪事:在dbgrid输入20.2 却变成了20.199(数据库为sql2000,数据类型为numeric(10,3)
FileNames := StringReplace(Trim(adoQuery1.FieldList.Text), #13#10, ';', [rfReplaceAll]);
while not adoQuery1.Eof do begin
Table1.Append;
Table1[FileNames] := adoQuery1[FileNames];
Table1.Post;
adoQuery1.Next;是否只对一个字段进行操作啊
begin
table1.Append;
table1.Fields.fields[0]:=adoQuery1.fields.fields[0];
table1.Fields.fields[1]:=adoQuery1.fields.fields[1];
table1.Fields.fields[2]:=adoQuery1.fields.fields[2];
table1.Fields.fields[3]:=adoQuery1.fields.fields[3];
adoQuery1.Next;
table1.Post;
end
我的程序里table1.Fields.fields[0]就是table1的id字段
SELECT INTO
它是不是也有一个id?是不是也是自动增加的?//肯定是啊;
所以不要给id给值就可以了;
看了您的回复,我把代码改为:
procedure TForm1.Button6Click(Sender: TObject);
var
FileNames: string;
i:integer;
begin
Table1.Close;
Table1.FieldDefs.Assign(adoQuery1.FieldDefs);
Table1.TableName := 'NewTable';
Table1.CreateTable;
Table1.Open;
for i:=1 to adoQuery1.recordcount do
begin
table1.Append;
table1.Fields.fields[0]:=adoQuery1.fields.fields[0];
table1.Fields.fields[1]:=adoQuery1.fields.fields[1];
table1.Fields.fields[2]:=adoQuery1.fields.fields[2];
table1.Fields.fields[3]:=adoQuery1.fields.fields[3];
adoQuery1.Next;
table1.Post;
end;
end;
但是还是不行呀,错误提示还是field id can't be modified.那个id就是sql server数据库的那个只读的id字段呀!
table1.fields.fields[0]:=adoQuery.fields.fields[0]删除后
再试试
难道让我辞职吗?
SOS!
table1.Fields.fields[3]:=adoQuery1.fields.fields[3];
删除就可以了哦!!!谢谢小熊!!!过会结帐!!