日期:2014-05-18 浏览次数:20509 次
--if object_id('CHENGJI') is not null drop table CHENGJI --create table CHENGJI --( -- id int NOT NULL, -- chengji int NOT NULL, -- xingming varchar(30) NOT NULL, -- banji int NOT NULL --) --insert CHENGJI --select 1,90,'张三',14 union --select 2,70,'李四',17 union --select 3,80,'张三',14 union --select 4,60,'张三',14 union --select 5,77,'李四',17 union --select 6,80,'张三',14 union --select 7,90,'李四',17 union --select 8,70,'李四',17 --go declare @Sql varchar(300) declare @chengji int Set @chengji=80 Set @Sql=' Select id,chengji,xingming ,banji From CHENGJI Where chengji='+cast(@Chengji as varchar(10)) Print(@Sql) exec(@Sql)
procedure TForm1.Button1Click(Sender: TObject); begin ADOQuery1.Close; ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add('Select id,chengji,banji,xingming From CHENGJI where chengji=80'); ADOQuery1.Open; Memo1.Lines.Clear; While ADOQuery1.Eof =false do begin Memo1.Lines.Add(ADOQuery1.FieldByName('id').AsString); Memo1.Lines.Add(IntToStr(ADOQuery1.FieldByName('chengji').AsInteger)); Memo1.Lines.Add(ADOQuery1.FieldByName('xingming').AsString); Memo1.Lines.Add(ADOQuery1.FieldByName('banji').AsString); ADOQuery1.Next; end; ADOQuery1.Close; end;