请高手看一下这一段程序:
name1,cz1都为椼string;
name1:=table6.FieldValues['11'];
while table6.Eof=false do
begin
if dyxm=name1 then
begin
table7.Open;
table7.Append;
table7.FieldValues['日期']:=table6.FieldValues['日期'];
table7.FieldValues['姓名']:=table6.FieldValues['姓名'];
table7.Post;
table7.Refresh;
end;
table6.Next;
name1:=table6.FieldValues['11'];
cz1:=table6.FieldValues['日期'];
if cz1>edit3.Text then break;
end;
这只是其中的一段程序,在我和程序中要调用到三次这段程序,但是在每一次用到时没有错,而在第二次用到时在“cz1:=table6.FieldValues['日期'];”出现了错误:Invalid variant type Concersion 无效的变量类型转换。
请问应如何写才会不出现这个错误。谢谢了!!!!
name1,cz1都为椼string;
name1:=table6.FieldValues['11'];
while table6.Eof=false do
begin
if dyxm=name1 then
begin
table7.Open;
table7.Append;
table7.FieldValues['日期']:=table6.FieldValues['日期'];
table7.FieldValues['姓名']:=table6.FieldValues['姓名'];
table7.Post;
table7.Refresh;
end;
table6.Next;
name1:=table6.FieldValues['11'];
cz1:=table6.FieldValues['日期'];
if cz1>edit3.Text then break;
end;
这只是其中的一段程序,在我和程序中要调用到三次这段程序,但是在每一次用到时没有错,而在第二次用到时在“cz1:=table6.FieldValues['日期'];”出现了错误:Invalid variant type Concersion 无效的变量类型转换。
请问应如何写才会不出现这个错误。谢谢了!!!!
解决方案 »
- 请教,保存主子表的思路,是分别保存,还是一同保存呢?
- 请教个简单的问题,初学 见笑了
- 怎样获取参数
- Copy两个DataSet,难死所有高手!
- 100分跪求:函数中为什么不能用ADOQuery????
- 高手请进!!!
- *****麻烦大家看看这个错误怎么解决!![Fatal Error] XMLUtils.pas(24): Read error on '.\output\Unicode.dcu'
- 在delphi5和sql server7.0中如何存取9位小数?
- 高手请进
- 请各位高手出手相助,关于installshield的“make tegistry changes”中的设定问题
- 这个SQL怎么写啊?
- 结果怎么会是这样?请进来看看!!!
->
table6.FieldByName('11').AsString 如果table6.FieldValues['11'] 可能为空的话,肯定会出问题的;
建议取值时用下面这种方式;
1、
while table6.Eof=false do
=》
while not table6.eof do2、
if dyxm=name1 then
=》
if UpperCase(dyxm) = UpperCase(name1) then3、
table7.FieldValues['日期']:=table6.FieldValues['日期'];
=》
table7.FieldValues['日期'] := table6.FieldByName('日期').AsVariant;