Person表,字段Person .iPCode
查询Person表的iPCode字段,并从小到大排列
select Person .iPCode from Person
order by scardcode
假设查询结果为RSA:1,2,5,8,9
查询Seat表的idisplay字段,并从小到大排列
select iDisplay from TABLE_Seat
where irow=:prow and idisplay>0 //每行的idisplay都从1开始
order by idisplay
假设查询结果为RSB:5 9 11 12 13
如何将RSA中的结果按小对小的关系插入到RSB的Seat.iPCode中
既按: RSA 对应 RSB
1 5
2 9
5 11
8 12
9 13
18 个解决方案
#1
看得挺晕的~
#2
插入肯定不行,用利用跟新update
1:首先把RSB插入到Seat.iPCode中
2:With AdoQuery1 do
Begin
******order by //查询到你结果 SA:1,2,5,8,9
End;
while not AdoQuery1.eof do
Begin
select min(idisplay )as ** from Seat where iPCode='''' //获取最小的值并且没有跟新的iPCode等于空
update Seat set iPCode='''+Adoquery('')*****+'''where idisplay ='''+上面获取的最小值+'''//这里直接就跟新到系统
AdoQuery1.next;
End;
Showmessage('跟新成功');
1:首先把RSB插入到Seat.iPCode中
2:With AdoQuery1 do
Begin
******order by //查询到你结果 SA:1,2,5,8,9
End;
while not AdoQuery1.eof do
Begin
select min(idisplay )as ** from Seat where iPCode='''' //获取最小的值并且没有跟新的iPCode等于空
update Seat set iPCode='''+Adoquery('')*****+'''where idisplay ='''+上面获取的最小值+'''//这里直接就跟新到系统
AdoQuery1.next;
End;
Showmessage('跟新成功');
#3
怎么发贴乱吗了?
update Seat set iPCode='''+Adoquery1.fieldbyname('Column').Asstring where idisplay=上面获取的最小值 ;//这里直接就跟新到系统
AdoQuery1.next;
End;
跟新成功
update Seat set iPCode='''+Adoquery1.fieldbyname('Column').Asstring where idisplay=上面获取的最小值 ;//这里直接就跟新到系统
AdoQuery1.next;
End;
跟新成功
#4
晕!!!发的贴怎么乱成这个样子
口述:思路
方法1 1:首先对RSA的结果排序从小到大
2:RSb的结果插入到Seat的idisplay (RSB:5 9 11 12 13 )
3:在利用RSA查询的结果循环(再找Seat的idisplay最小数并要求跟新的字段iPCode为空),接下来跟新
方法2:可以建立临时表Clientdataset 跟心到Seat
1:首先获取要跟新的表的行数count(*)
2:对得到RSA,RSB的顺序
2: 利用for循环分别付值
for i:=1 to Cont(*)
Begin
循环RSA;
循环RSB;
付值//思路和1的思路一样
End;
口述:思路
方法1 1:首先对RSA的结果排序从小到大
2:RSb的结果插入到Seat的idisplay (RSB:5 9 11 12 13 )
3:在利用RSA查询的结果循环(再找Seat的idisplay最小数并要求跟新的字段iPCode为空),接下来跟新
方法2:可以建立临时表Clientdataset 跟心到Seat
1:首先获取要跟新的表的行数count(*)
2:对得到RSA,RSB的顺序
2: 利用for循环分别付值
for i:=1 to Cont(*)
Begin
循环RSA;
循环RSB;
付值//思路和1的思路一样
End;
#5
RSA是从Person表里查询得到的Person.iPCode的有序结果集(从小到大)
Person.iPCode在Seat表中字段名为Seat.iPCode,默认值为-1;
RSB是从Seat表里查询得到的iDisplay的有序结果集(从大到小)
iDisplay在每行(irow)中均从1开始;
//以下程序希望实现功能:
//if TABLE_Delegation.scardcode最小 &&TABLE_Seat.idisplay最小
TABLE_Delegation.scardcode插入到TABLE_Seat.iperson_ID中
procedure TFormSeatCreate.ButtonPersonClick(Sender: TObject);
var Row,MinRow,MaxRow,i,j:integer;
abc,def:string;
begin
with ADOQSeat do
begin
Close;
SQL.Clear;
SQL.Add('select min(iRow) MinRow ,max(iRow) MaxRow from TABLE_Seat');
open;
MinRow:=FieldValues['MinRow'];//查询行数
MaxRow:=FieldValues['MaxRow'];
end;
for Row:=MinRow to MaxRow do //从小到大依次执行所有行
begin
with ADOQSeat do
begin
Close;
SQL.Clear;
SQL.Add('select scardcode from TABLE_Delegation order by scardcode');
open;
end; //从人员信息表查询卡号,并排序
while ADOQSeat.Eof do
begin
ADOQSeat.Close;
ADOQSeat.SQL.Clear;
ADOQSeat.SQL.Add('select min(iDisplay) Display from TABLE_Seat where irow=:prow and idisplay>0');
ADOQSeat.Parameters.ParamByName('prow').Value:=Row; //每次循环的ROW
ADOQSeat.open;
abc:=ADOQSeat.FieldbyName('Display').AsString;
ADOQSeat.Close;
ADOQSeat.SQL.Clear;
ADOQSeat.SQL.Add('update TABLE_Seat iperson_ID=:pperson_ID where idisplay=:pdisplay');
ADOQSeat.Parameters.ParamByName('iperson_ID').Value:=ADOQSeat.FieldByName('scardcode').AsString; //每次循环的ROW
ADOQSeat.Parameters.ParamByName('pdisplay').Value:=abc; //每次循环的ROW
ADOQSeat.Next;
end;
end;
showmessage('OK');
end;
回寝室了。。。小米+步枪请再帮看看。。。谢谢~~~
Person.iPCode在Seat表中字段名为Seat.iPCode,默认值为-1;
RSB是从Seat表里查询得到的iDisplay的有序结果集(从大到小)
iDisplay在每行(irow)中均从1开始;
//以下程序希望实现功能:
//if TABLE_Delegation.scardcode最小 &&TABLE_Seat.idisplay最小
TABLE_Delegation.scardcode插入到TABLE_Seat.iperson_ID中
procedure TFormSeatCreate.ButtonPersonClick(Sender: TObject);
var Row,MinRow,MaxRow,i,j:integer;
abc,def:string;
begin
with ADOQSeat do
begin
Close;
SQL.Clear;
SQL.Add('select min(iRow) MinRow ,max(iRow) MaxRow from TABLE_Seat');
open;
MinRow:=FieldValues['MinRow'];//查询行数
MaxRow:=FieldValues['MaxRow'];
end;
for Row:=MinRow to MaxRow do //从小到大依次执行所有行
begin
with ADOQSeat do
begin
Close;
SQL.Clear;
SQL.Add('select scardcode from TABLE_Delegation order by scardcode');
open;
end; //从人员信息表查询卡号,并排序
while ADOQSeat.Eof do
begin
ADOQSeat.Close;
ADOQSeat.SQL.Clear;
ADOQSeat.SQL.Add('select min(iDisplay) Display from TABLE_Seat where irow=:prow and idisplay>0');
ADOQSeat.Parameters.ParamByName('prow').Value:=Row; //每次循环的ROW
ADOQSeat.open;
abc:=ADOQSeat.FieldbyName('Display').AsString;
ADOQSeat.Close;
ADOQSeat.SQL.Clear;
ADOQSeat.SQL.Add('update TABLE_Seat iperson_ID=:pperson_ID where idisplay=:pdisplay');
ADOQSeat.Parameters.ParamByName('iperson_ID').Value:=ADOQSeat.FieldByName('scardcode').AsString; //每次循环的ROW
ADOQSeat.Parameters.ParamByName('pdisplay').Value:=abc; //每次循环的ROW
ADOQSeat.Next;
end;
end;
showmessage('OK');
end;
回寝室了。。。小米+步枪请再帮看看。。。谢谢~~~
#6
大家帮忙看看,3点半前没课,在线等~~
#7
你自己调试一下,,看有什么样的结果,,,,
#8
----上面的代码我不看了,,太乱了,,,简单重复
方法1 1:首先对RSA的结果排序从小到大 RSA:1,2,5,8,9
2:RSb的结果插入到Seat的idisplay (RSB:5 9 11 12 13 )
3:在利用RSA查询的结果循环跟新 ,在找每次找Seat的idisplay最小数(min(idisplay))并要求跟新的字段iPCode为默认值为-1(这里一定要加上,以区别已经跟新
)
...........
while ADOQSeat.Eof do //ADOQSeat是跟新为RSA:1,2,5,8,9 结果的ADOQSeat
begin
withn ADOQSeat1 do
Begin
.......
sql.add('select min(idisplay) as idisplay_ from Seat where iPCode=''-1'' ');//查询最小RSB
........
End;
....
sql.addd('update set iPCode='''+ADOQSeat.Fieldbyname(iPCode_ ').Asstring+''' where idisplay='''+ADOQSeat1.Fieldbyname(idisplay_ ').Asstring+'''') //跟新
ADOQSeat.Next;
end;
showmessage( 'OK ');
end;
方法1 1:首先对RSA的结果排序从小到大 RSA:1,2,5,8,9
2:RSb的结果插入到Seat的idisplay (RSB:5 9 11 12 13 )
3:在利用RSA查询的结果循环跟新 ,在找每次找Seat的idisplay最小数(min(idisplay))并要求跟新的字段iPCode为默认值为-1(这里一定要加上,以区别已经跟新
)
...........
while ADOQSeat.Eof do //ADOQSeat是跟新为RSA:1,2,5,8,9 结果的ADOQSeat
begin
withn ADOQSeat1 do
Begin
.......
sql.add('select min(idisplay) as idisplay_ from Seat where iPCode=''-1'' ');//查询最小RSB
........
End;
....
sql.addd('update set iPCode='''+ADOQSeat.Fieldbyname(iPCode_ ').Asstring+''' where idisplay='''+ADOQSeat1.Fieldbyname(idisplay_ ').Asstring+'''') //跟新
ADOQSeat.Next;
end;
showmessage( 'OK ');
end;
#9
运行到下面ADOQSeat.Next时提示
Cannot perform this operation on a closed dataset
ADOQSeat.Parameters.ParamByName( 'pdisplay ').Value:=abc; //每次循环的ROW
ADOQSeat.Next;
end;
Cannot perform this operation on a closed dataset
ADOQSeat.Parameters.ParamByName( 'pdisplay ').Value:=abc; //每次循环的ROW
ADOQSeat.Next;
end;
#10
annot perform this operation on a closed dataset
提示:数据库没有处于编辑状态或已经关闭,,,
ADOQSeat.SQL.Add( 'update TABLE_Seat iperson_ID=:pperson_ID where idisplay=:pdisplay ');
------
ADOCommand1.CommandText:=‘跟新语句’;
少了ADOCommand1.Execute //ADOCommand1用这个控件更新,,
提示:数据库没有处于编辑状态或已经关闭,,,
ADOQSeat.SQL.Add( 'update TABLE_Seat iperson_ID=:pperson_ID where idisplay=:pdisplay ');
------
ADOCommand1.CommandText:=‘跟新语句’;
少了ADOCommand1.Execute //ADOCommand1用这个控件更新,,
#11
to yangfana
整个过程都是用一个ADOQSeat,晕,那样肯定是错的,,,还没有执行呢ADOQSeat的sql语句,又关闭执行另一个语句,,,,
整个过程都是用一个ADOQSeat,晕,那样肯定是错的,,,还没有执行呢ADOQSeat的sql语句,又关闭执行另一个语句,,,,
#12
郁闷 上课了 晚上来继续。。。真麻烦你了。。。
#13
已经可以更新了,但是一点按钮进程就无响应,还没来得及调试。。。
十分谢谢!~~
十分谢谢!~~
#14
WANGXUELLD 能否留个联系方法?
#15
我正在帮你做,,,等一下,,马上就好,,等一下发给你,,
#16
-------------过程我给你简化了,,,
-:建立表
Create table seat (
idisplay int ,
iPCode int )
--------------------
2:建立表
Create table Person (
iPCode int,
idisplay int )
3:select iPCode , idisplay from seat order by idisplay //付值和查询结果
结果为: -1,5
-1,9
-1,11
-1,12
-1,13
4: select iPCode from Person order by iPCode //付值和查询结果
结果为RSA 1,2,5,8,9
5:程序代码:把RSA跟新set表的iPCode 字段以小对小的关系
procedure TForm1.Button4Click(Sender: TObject);
begin
With AdoQuery1 do
Begin
Close;
SQl.Clear ;
SQl.Add('select iPCode from Person order by iPCode'); //得到rsa结果
open;
end;
While Not AdoQuery1.Eof do
Begin
with AdoQuery2 do
Begin
Close;
SQl.Clear ;
SQl.Add('select min(idisplay) as idisplay from seat where iPCode=''-1'' order by idisplay '); //获取每次得到RSB的最小值 ;哪个-1是唯一区别
open;
End;
With adoQuery3 do
Begin
Close;
SQl.Clear ;
SQl.Add('update seat set iPCode='''+Adoquery1.fieldbyname('iPCode').AsString +''''
+' where idisplay='''+adoquery2.fieldbyname('idisplay').AsString +''' ');
ExecSQL ;
End;
AdoQuery1.Next ;
End;
end;
测试通过,,,我的QQ290843309如果在有什么问题QQ联系,,
-:建立表
Create table seat (
idisplay int ,
iPCode int )
--------------------
2:建立表
Create table Person (
iPCode int,
idisplay int )
3:select iPCode , idisplay from seat order by idisplay //付值和查询结果
结果为: -1,5
-1,9
-1,11
-1,12
-1,13
4: select iPCode from Person order by iPCode //付值和查询结果
结果为RSA 1,2,5,8,9
5:程序代码:把RSA跟新set表的iPCode 字段以小对小的关系
procedure TForm1.Button4Click(Sender: TObject);
begin
With AdoQuery1 do
Begin
Close;
SQl.Clear ;
SQl.Add('select iPCode from Person order by iPCode'); //得到rsa结果
open;
end;
While Not AdoQuery1.Eof do
Begin
with AdoQuery2 do
Begin
Close;
SQl.Clear ;
SQl.Add('select min(idisplay) as idisplay from seat where iPCode=''-1'' order by idisplay '); //获取每次得到RSB的最小值 ;哪个-1是唯一区别
open;
End;
With adoQuery3 do
Begin
Close;
SQl.Clear ;
SQl.Add('update seat set iPCode='''+Adoquery1.fieldbyname('iPCode').AsString +''''
+' where idisplay='''+adoquery2.fieldbyname('idisplay').AsString +''' ');
ExecSQL ;
End;
AdoQuery1.Next ;
End;
end;
测试通过,,,我的QQ290843309如果在有什么问题QQ联系,,
#17
结果: 1 5
2 9
5 11
8 12
9 13
2 9
5 11
8 12
9 13
#18
已经OK,结贴。再次感谢
#1
看得挺晕的~
#2
插入肯定不行,用利用跟新update
1:首先把RSB插入到Seat.iPCode中
2:With AdoQuery1 do
Begin
******order by //查询到你结果 SA:1,2,5,8,9
End;
while not AdoQuery1.eof do
Begin
select min(idisplay )as ** from Seat where iPCode='''' //获取最小的值并且没有跟新的iPCode等于空
update Seat set iPCode='''+Adoquery('')*****+'''where idisplay ='''+上面获取的最小值+'''//这里直接就跟新到系统
AdoQuery1.next;
End;
Showmessage('跟新成功');
1:首先把RSB插入到Seat.iPCode中
2:With AdoQuery1 do
Begin
******order by //查询到你结果 SA:1,2,5,8,9
End;
while not AdoQuery1.eof do
Begin
select min(idisplay )as ** from Seat where iPCode='''' //获取最小的值并且没有跟新的iPCode等于空
update Seat set iPCode='''+Adoquery('')*****+'''where idisplay ='''+上面获取的最小值+'''//这里直接就跟新到系统
AdoQuery1.next;
End;
Showmessage('跟新成功');
#3
怎么发贴乱吗了?
update Seat set iPCode='''+Adoquery1.fieldbyname('Column').Asstring where idisplay=上面获取的最小值 ;//这里直接就跟新到系统
AdoQuery1.next;
End;
跟新成功
update Seat set iPCode='''+Adoquery1.fieldbyname('Column').Asstring where idisplay=上面获取的最小值 ;//这里直接就跟新到系统
AdoQuery1.next;
End;
跟新成功
#4
晕!!!发的贴怎么乱成这个样子
口述:思路
方法1 1:首先对RSA的结果排序从小到大
2:RSb的结果插入到Seat的idisplay (RSB:5 9 11 12 13 )
3:在利用RSA查询的结果循环(再找Seat的idisplay最小数并要求跟新的字段iPCode为空),接下来跟新
方法2:可以建立临时表Clientdataset 跟心到Seat
1:首先获取要跟新的表的行数count(*)
2:对得到RSA,RSB的顺序
2: 利用for循环分别付值
for i:=1 to Cont(*)
Begin
循环RSA;
循环RSB;
付值//思路和1的思路一样
End;
口述:思路
方法1 1:首先对RSA的结果排序从小到大
2:RSb的结果插入到Seat的idisplay (RSB:5 9 11 12 13 )
3:在利用RSA查询的结果循环(再找Seat的idisplay最小数并要求跟新的字段iPCode为空),接下来跟新
方法2:可以建立临时表Clientdataset 跟心到Seat
1:首先获取要跟新的表的行数count(*)
2:对得到RSA,RSB的顺序
2: 利用for循环分别付值
for i:=1 to Cont(*)
Begin
循环RSA;
循环RSB;
付值//思路和1的思路一样
End;
#5
RSA是从Person表里查询得到的Person.iPCode的有序结果集(从小到大)
Person.iPCode在Seat表中字段名为Seat.iPCode,默认值为-1;
RSB是从Seat表里查询得到的iDisplay的有序结果集(从大到小)
iDisplay在每行(irow)中均从1开始;
//以下程序希望实现功能:
//if TABLE_Delegation.scardcode最小 &&TABLE_Seat.idisplay最小
TABLE_Delegation.scardcode插入到TABLE_Seat.iperson_ID中
procedure TFormSeatCreate.ButtonPersonClick(Sender: TObject);
var Row,MinRow,MaxRow,i,j:integer;
abc,def:string;
begin
with ADOQSeat do
begin
Close;
SQL.Clear;
SQL.Add('select min(iRow) MinRow ,max(iRow) MaxRow from TABLE_Seat');
open;
MinRow:=FieldValues['MinRow'];//查询行数
MaxRow:=FieldValues['MaxRow'];
end;
for Row:=MinRow to MaxRow do //从小到大依次执行所有行
begin
with ADOQSeat do
begin
Close;
SQL.Clear;
SQL.Add('select scardcode from TABLE_Delegation order by scardcode');
open;
end; //从人员信息表查询卡号,并排序
while ADOQSeat.Eof do
begin
ADOQSeat.Close;
ADOQSeat.SQL.Clear;
ADOQSeat.SQL.Add('select min(iDisplay) Display from TABLE_Seat where irow=:prow and idisplay>0');
ADOQSeat.Parameters.ParamByName('prow').Value:=Row; //每次循环的ROW
ADOQSeat.open;
abc:=ADOQSeat.FieldbyName('Display').AsString;
ADOQSeat.Close;
ADOQSeat.SQL.Clear;
ADOQSeat.SQL.Add('update TABLE_Seat iperson_ID=:pperson_ID where idisplay=:pdisplay');
ADOQSeat.Parameters.ParamByName('iperson_ID').Value:=ADOQSeat.FieldByName('scardcode').AsString; //每次循环的ROW
ADOQSeat.Parameters.ParamByName('pdisplay').Value:=abc; //每次循环的ROW
ADOQSeat.Next;
end;
end;
showmessage('OK');
end;
回寝室了。。。小米+步枪请再帮看看。。。谢谢~~~
Person.iPCode在Seat表中字段名为Seat.iPCode,默认值为-1;
RSB是从Seat表里查询得到的iDisplay的有序结果集(从大到小)
iDisplay在每行(irow)中均从1开始;
//以下程序希望实现功能:
//if TABLE_Delegation.scardcode最小 &&TABLE_Seat.idisplay最小
TABLE_Delegation.scardcode插入到TABLE_Seat.iperson_ID中
procedure TFormSeatCreate.ButtonPersonClick(Sender: TObject);
var Row,MinRow,MaxRow,i,j:integer;
abc,def:string;
begin
with ADOQSeat do
begin
Close;
SQL.Clear;
SQL.Add('select min(iRow) MinRow ,max(iRow) MaxRow from TABLE_Seat');
open;
MinRow:=FieldValues['MinRow'];//查询行数
MaxRow:=FieldValues['MaxRow'];
end;
for Row:=MinRow to MaxRow do //从小到大依次执行所有行
begin
with ADOQSeat do
begin
Close;
SQL.Clear;
SQL.Add('select scardcode from TABLE_Delegation order by scardcode');
open;
end; //从人员信息表查询卡号,并排序
while ADOQSeat.Eof do
begin
ADOQSeat.Close;
ADOQSeat.SQL.Clear;
ADOQSeat.SQL.Add('select min(iDisplay) Display from TABLE_Seat where irow=:prow and idisplay>0');
ADOQSeat.Parameters.ParamByName('prow').Value:=Row; //每次循环的ROW
ADOQSeat.open;
abc:=ADOQSeat.FieldbyName('Display').AsString;
ADOQSeat.Close;
ADOQSeat.SQL.Clear;
ADOQSeat.SQL.Add('update TABLE_Seat iperson_ID=:pperson_ID where idisplay=:pdisplay');
ADOQSeat.Parameters.ParamByName('iperson_ID').Value:=ADOQSeat.FieldByName('scardcode').AsString; //每次循环的ROW
ADOQSeat.Parameters.ParamByName('pdisplay').Value:=abc; //每次循环的ROW
ADOQSeat.Next;
end;
end;
showmessage('OK');
end;
回寝室了。。。小米+步枪请再帮看看。。。谢谢~~~
#6
大家帮忙看看,3点半前没课,在线等~~
#7
你自己调试一下,,看有什么样的结果,,,,
#8
----上面的代码我不看了,,太乱了,,,简单重复
方法1 1:首先对RSA的结果排序从小到大 RSA:1,2,5,8,9
2:RSb的结果插入到Seat的idisplay (RSB:5 9 11 12 13 )
3:在利用RSA查询的结果循环跟新 ,在找每次找Seat的idisplay最小数(min(idisplay))并要求跟新的字段iPCode为默认值为-1(这里一定要加上,以区别已经跟新
)
...........
while ADOQSeat.Eof do //ADOQSeat是跟新为RSA:1,2,5,8,9 结果的ADOQSeat
begin
withn ADOQSeat1 do
Begin
.......
sql.add('select min(idisplay) as idisplay_ from Seat where iPCode=''-1'' ');//查询最小RSB
........
End;
....
sql.addd('update set iPCode='''+ADOQSeat.Fieldbyname(iPCode_ ').Asstring+''' where idisplay='''+ADOQSeat1.Fieldbyname(idisplay_ ').Asstring+'''') //跟新
ADOQSeat.Next;
end;
showmessage( 'OK ');
end;
方法1 1:首先对RSA的结果排序从小到大 RSA:1,2,5,8,9
2:RSb的结果插入到Seat的idisplay (RSB:5 9 11 12 13 )
3:在利用RSA查询的结果循环跟新 ,在找每次找Seat的idisplay最小数(min(idisplay))并要求跟新的字段iPCode为默认值为-1(这里一定要加上,以区别已经跟新
)
...........
while ADOQSeat.Eof do //ADOQSeat是跟新为RSA:1,2,5,8,9 结果的ADOQSeat
begin
withn ADOQSeat1 do
Begin
.......
sql.add('select min(idisplay) as idisplay_ from Seat where iPCode=''-1'' ');//查询最小RSB
........
End;
....
sql.addd('update set iPCode='''+ADOQSeat.Fieldbyname(iPCode_ ').Asstring+''' where idisplay='''+ADOQSeat1.Fieldbyname(idisplay_ ').Asstring+'''') //跟新
ADOQSeat.Next;
end;
showmessage( 'OK ');
end;
#9
运行到下面ADOQSeat.Next时提示
Cannot perform this operation on a closed dataset
ADOQSeat.Parameters.ParamByName( 'pdisplay ').Value:=abc; //每次循环的ROW
ADOQSeat.Next;
end;
Cannot perform this operation on a closed dataset
ADOQSeat.Parameters.ParamByName( 'pdisplay ').Value:=abc; //每次循环的ROW
ADOQSeat.Next;
end;
#10
annot perform this operation on a closed dataset
提示:数据库没有处于编辑状态或已经关闭,,,
ADOQSeat.SQL.Add( 'update TABLE_Seat iperson_ID=:pperson_ID where idisplay=:pdisplay ');
------
ADOCommand1.CommandText:=‘跟新语句’;
少了ADOCommand1.Execute //ADOCommand1用这个控件更新,,
提示:数据库没有处于编辑状态或已经关闭,,,
ADOQSeat.SQL.Add( 'update TABLE_Seat iperson_ID=:pperson_ID where idisplay=:pdisplay ');
------
ADOCommand1.CommandText:=‘跟新语句’;
少了ADOCommand1.Execute //ADOCommand1用这个控件更新,,
#11
to yangfana
整个过程都是用一个ADOQSeat,晕,那样肯定是错的,,,还没有执行呢ADOQSeat的sql语句,又关闭执行另一个语句,,,,
整个过程都是用一个ADOQSeat,晕,那样肯定是错的,,,还没有执行呢ADOQSeat的sql语句,又关闭执行另一个语句,,,,
#12
郁闷 上课了 晚上来继续。。。真麻烦你了。。。
#13
已经可以更新了,但是一点按钮进程就无响应,还没来得及调试。。。
十分谢谢!~~
十分谢谢!~~
#14
WANGXUELLD 能否留个联系方法?
#15
我正在帮你做,,,等一下,,马上就好,,等一下发给你,,
#16
-------------过程我给你简化了,,,
-:建立表
Create table seat (
idisplay int ,
iPCode int )
--------------------
2:建立表
Create table Person (
iPCode int,
idisplay int )
3:select iPCode , idisplay from seat order by idisplay //付值和查询结果
结果为: -1,5
-1,9
-1,11
-1,12
-1,13
4: select iPCode from Person order by iPCode //付值和查询结果
结果为RSA 1,2,5,8,9
5:程序代码:把RSA跟新set表的iPCode 字段以小对小的关系
procedure TForm1.Button4Click(Sender: TObject);
begin
With AdoQuery1 do
Begin
Close;
SQl.Clear ;
SQl.Add('select iPCode from Person order by iPCode'); //得到rsa结果
open;
end;
While Not AdoQuery1.Eof do
Begin
with AdoQuery2 do
Begin
Close;
SQl.Clear ;
SQl.Add('select min(idisplay) as idisplay from seat where iPCode=''-1'' order by idisplay '); //获取每次得到RSB的最小值 ;哪个-1是唯一区别
open;
End;
With adoQuery3 do
Begin
Close;
SQl.Clear ;
SQl.Add('update seat set iPCode='''+Adoquery1.fieldbyname('iPCode').AsString +''''
+' where idisplay='''+adoquery2.fieldbyname('idisplay').AsString +''' ');
ExecSQL ;
End;
AdoQuery1.Next ;
End;
end;
测试通过,,,我的QQ290843309如果在有什么问题QQ联系,,
-:建立表
Create table seat (
idisplay int ,
iPCode int )
--------------------
2:建立表
Create table Person (
iPCode int,
idisplay int )
3:select iPCode , idisplay from seat order by idisplay //付值和查询结果
结果为: -1,5
-1,9
-1,11
-1,12
-1,13
4: select iPCode from Person order by iPCode //付值和查询结果
结果为RSA 1,2,5,8,9
5:程序代码:把RSA跟新set表的iPCode 字段以小对小的关系
procedure TForm1.Button4Click(Sender: TObject);
begin
With AdoQuery1 do
Begin
Close;
SQl.Clear ;
SQl.Add('select iPCode from Person order by iPCode'); //得到rsa结果
open;
end;
While Not AdoQuery1.Eof do
Begin
with AdoQuery2 do
Begin
Close;
SQl.Clear ;
SQl.Add('select min(idisplay) as idisplay from seat where iPCode=''-1'' order by idisplay '); //获取每次得到RSB的最小值 ;哪个-1是唯一区别
open;
End;
With adoQuery3 do
Begin
Close;
SQl.Clear ;
SQl.Add('update seat set iPCode='''+Adoquery1.fieldbyname('iPCode').AsString +''''
+' where idisplay='''+adoquery2.fieldbyname('idisplay').AsString +''' ');
ExecSQL ;
End;
AdoQuery1.Next ;
End;
end;
测试通过,,,我的QQ290843309如果在有什么问题QQ联系,,
#17
结果: 1 5
2 9
5 11
8 12
9 13
2 9
5 11
8 12
9 13
#18
已经OK,结贴。再次感谢