标识种子怎么写到数据库?
我在用StringGrid把几条记录同时写到数据库,我想给每条记录写进去后自增一个ID号,如100,101,102这样。但我在表里增加了一个字段dj_id ,数据类型numerc,
但在同时写几条记录的时候就不行了(如果没有这个字段是可以的),是不是跟我同时写几条记录有关系啊?
我的代码如下:
procedure Txinzengfm.BitBtn1Click(Sender: TObject);
var
i,j: Integer;
begin
ADODataSet1.Open;
ADODataSet1.Append;
if Length(Edit1.Text)<>7 then
Application.MessageBox('你输入的出厂编号是不合法的,请检查是否为七位的编号!','提示信息',MB_OK)
else if ComboBox1.Text='' then
Application.MessageBox('为了方便以后的统计,请选择产品规格','提示信息',MB_OK)
else if ComboBox2.Text='' then
Application.MessageBox('为了方便以后的统计,请选择销售性质','提示信息',MB_OK)
else if Edit2.Text='' then
Application.MessageBox('为了方便以后的统计,请选择产品型号','提示信息',MB_OK)
else
begin
ADODataSet1.FieldByName('ccbh').AsString:=Edit1.Text;
ADODataSet1.FieldByName('zp_rq').AsString:=DateTimeToStr(DateTimePicker1.DateTime);
ADODataSet1.FieldByName('cpgg_mc').AsString:=ComboBox1.Items[ComboBox1.ItemIndex];
ADODataSet1.FieldByName('cpgg_id').AsString:=s1;
ADODataSet1.FieldByName('xsxz_mc').AsString:=ComboBox2.Items[ComboBox2.ItemIndex];
ADODataSet1.FieldByName('xsxz_id').AsString:=s2;
ADODataSet1.FieldByName('cpxh_mc').AsString:=Edit2.Text;
ADODataSet1.FieldByName('cpxh_id').AsString:=s3;
ADODataSet1.FieldByName('bz').AsString:=Edit3.Text;
ADODataSet1.Post;
end;
for i:=1 to StringGrid1.RowCount-1 do
begin
ADODataSet3.Append;
for j :=0 to StringGrid1.ColCount do
ADODataSet3.Fields[j].AsString:=StringGrid1.Cells[j,i]
end;
ADODataSet3.Post;
close;
end;