B
bamfk1023
Unregistered / Unconfirmed
GUEST, unregistred user!
---库结构如下 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t1]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[t1] GO CREATE TABLE [dbo].[t1] ( [id] [bigint] NOT NULL , [rname] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [small] [int] NULL , [zdke] [bigint] NULL , [def] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [t1] [datetime] NULL , [t2] [datetime] NULL ) ON [PRIMARY] GO ALTER TABLE [dbo].[t1] ADD CONSTRAINT [PK_t1] PRIMARY KEY CLUSTERED ( [id] ) ON [PRIMARY] GO D代码如下: procedure TForm1.Button1Click(Sender: TObject); var i:integer; begin with ADOQuery1 do begin close; SQL.Text := 'select * from t1'; open; append; for i:=0 to Fields.count-1 do begin case Fields.DataType of ftString:Fields.AsString := '111'; ftWideString:Fields.AsString := '111'; ftDate:Fields.AsDateTime := date; ftDateTime:Fields.AsDateTime := Date; ftInteger:Fields.AsInteger := 123; ftLargeint:TLargeintField(Fields).AsLargeInt := 123; else Fields.AsInteger := 123; end ; end ; end ; end; procedure TForm1.Button2Click(Sender: TObject); begin ADOQuery1.Post; // ~~~~~~~~~~~出现 EvariantBadVarTypeError: Invalid variant type end; 多简单的代码呀 不知道错在哪 ...