query1.close; query1.sql.clear; query1.sql.add('select * from table1 where 年份=2000 and 学期=''上'' and 部门=''机电'''); query1.open;
用TQuery嘛: SQL := 'Select * from table1 where 年份=''2000'' and 学期=''上'' and 部门=''机电'''; 设置它的RequestLive为True
用Filter呀 filtered=true filter= 年份='2000' and 学期='上' and 部门='机电'
table1.filter='年份=''2000'' and 学期=''上'' and 部门=''机电''' table1.filtered:=true;
Table1.Filtered := true; Table1.Filter := '年份=''2000'' and 学期=''上'' and 部门=''机电'''; table1.open;
table1.filter:='年份=''2000'' and 学期=''上'' and 部门=''机电'''; table1.filtered:=true;
table1.disablecontrols; table1.first; while not table1.eof do begin if table1.fieldbyname('年份').value=2000 and table1.fieldbyname('学期').value='上' and table1.fieldbyname('部门').value='机电' then .............//do what you want to do . table1.next; end; table1.enablecontrols;
如果我想让filter中 部门的值等于table2.fieldbyname('部门').value table2是另一个表,请问怎么写 我的这句话: form3.table3.filter:='年份=form3.edit3 and 上下半年=form3.combobox and 部门=form3.table1.FieldByName('部门').asstring'; 编译没通过,请问如何解决。
我的这句话form3.table3.filter:='年份=' + ''''+str1 +' and '+'上下半年=' + ''''+str2+' and '+ '部门=' + ''''+str3;编译通过了, 但执行时出现filter语句不正确的被终止,请帮忙分析一下。
请教locate()的用法,我实在是太菜了,多谢多谢。
请教locate()的用法,我实在是太菜了。多谢多谢。
table1.filtered:=false; table1.filter:='年份=''2000'' and 学期=''上'' and 部门=''机电'''; table1.filtered:=true; ----------------- table1.locate('年份','2000',[]);//详细请看帮助
你如果非要用table的话, str前后都要加引号 建议你改用query我的这句话form3.table3.filter:='年份=' + ''''+str1 +' and '+'上下半年=' + ''''+str2+' and '+ '部门=' + ''''+str3;编译通过了, 但执行时出现filter语句不正确的被终止,请帮忙分析一下。
with Table do Locate(年份;学期;部门', VarArrayOf(['2000', '上', '机电']), [loPartialKey]);
with Table do Locate('年份;学期;部门', VarArrayOf(['2000', '上', '机电']), [loPartialKey]);
你自己清不清楚你要做什么, 到底是定位某一条记录, 还是筛选出想要的记录locate是定位用的 Implements a virtual method for searching a dataset for a specified record and makes that record the active record.
query1.sql.clear;
query1.sql.add('select * from table1 where 年份=2000 and 学期=''上'' and 部门=''机电''');
query1.open;
SQL := 'Select * from table1 where 年份=''2000'' and 学期=''上'' and 部门=''机电''';
设置它的RequestLive为True
filtered=true
filter= 年份='2000' and 学期='上' and 部门='机电'
table1.filter='年份=''2000'' and 学期=''上'' and 部门=''机电'''
table1.filtered:=true;
Table1.Filter := '年份=''2000'' and 学期=''上'' and 部门=''机电''';
table1.open;
table1.filtered:=true;
table1.first;
while not table1.eof do
begin
if table1.fieldbyname('年份').value=2000 and
table1.fieldbyname('学期').value='上' and
table1.fieldbyname('部门').value='机电' then
.............//do what you want to do .
table1.next;
end;
table1.enablecontrols;
table2是另一个表,请问怎么写
我的这句话: form3.table3.filter:='年份=form3.edit3 and 上下半年=form3.combobox and 部门=form3.table1.FieldByName('部门').asstring';
编译没通过,请问如何解决。
str2:= form3.combobox;
str3:= form3.table1.FieldByName('部门').asstring';
form3.table3.filter:='年份=' + ''''+ str1 and ....
但执行时出现filter语句不正确的被终止,请帮忙分析一下。
table1.filter:='年份=''2000'' and 学期=''上'' and 部门=''机电''';
table1.filtered:=true;
-----------------
table1.locate('年份','2000',[]);//详细请看帮助
建议你改用query我的这句话form3.table3.filter:='年份=' + ''''+str1 +' and '+'上下半年=' + ''''+str2+' and '+ '部门=' + ''''+str3;编译通过了,
但执行时出现filter语句不正确的被终止,请帮忙分析一下。
Locate(年份;学期;部门', VarArrayOf(['2000', '上', '机电']), [loPartialKey]);
Locate('年份;学期;部门', VarArrayOf(['2000', '上', '机电']), [loPartialKey]);
执行后没有反应,我把它放在Table1AfterScroll事件里了,table1相当于它的主表,请问为何?
Locate('年份';'学期';'部门', VarArrayOf(['2000', '上', '机电']), [loPartialKey]);
相对应的记录,请问问题出现在哪,谢谢。
到底是定位某一条记录,
还是筛选出想要的记录locate是定位用的
Implements a virtual method for searching a dataset for a specified record and makes that record the active record.
我实在是不知道怎么办了。
我开始时用query做的,但搜索出的结果不能修改。用table又问题多多,
我脑袋有两个大了,过几天就要答辩了,愁啊。那位好心人帮帮我吧。
从多个表中select出的记录要修改的话
将query.requestlive:= true;
query.cachedupdates:= true;save之后用applyupdates提交到数据库
给你举个例子吧,你要付我网费:)
在窗体上放置一个Query1,和UpdateSql1
然后Query1连接数据库(不用我教了吧),按以下设置Query1的属性:
CacheUpdate设置为True
UpdateObject设置为UpdateSql1
然后Query1去查询数据,用UpdateSql1去修改数据,
可以在UpdateSql1控件上点鼠标右键,选择UpdateSql Editor项可以自动写SQL语句,就可以完成你的要求了
实际上Table完全可以实现你的要求,只是你的基本功太差,好好练练吧。
如果还是不会用的话,明天12点以后,我的QQ79383778,如果你现在在的话,也可以call我
你用Table做的话所有的查询是在你的前台完成的而不是后台,效率会非常低下。
with query do
begin
Close;
SQL.Add('select * from Table');
SQL.Add('where 年份 = "2000"‘);
SQL.Add('and 学期 = "上"');
SQL.Add('and 部门 = “机电”’);
Open;
end;
肯定没错!