我TADOQUERY(ADOQueChA)组件读取数据库时,当有个记录值为空时,出现提示错误,说不把把空值转换为字符,请问怎么解决这个问题啊
procedure TFrmNumeralTV.ShowChanNum; ////窗体显示时,频道分类标题同步显示
var
i:integer;
str1,str2:string;
begin
for i:=1 to 8 do
begin
With ADOQueCha do
begin
close;
SQL.Clear;
SQL.Add('select ParentKind from Chanel where ParentKindID=:ID');
parameters.ParamByName('ID').Value:=i;
open; STR1:=LEFTSTR(ADOQueChA.FieldValues['ParentKind'],3); //出现错误提示:不能把NULL转换为字符(STRING)
Case i of
1: LabTitle1.Caption:=STR1;
2: LabTitle2.Caption:=STR1;
3: LabTitle3.Caption:=STR1;
4: LabTitle4.Caption:=STR1;
5: LabTitle5.Caption:=STR1;
6: LabTitle6.Caption:=STR1;
7: LabTitle7.Caption:=STR1;
8: LabTitle8.Caption:=STR1;
end;
STR2:=ADOQueChA.FieldValues['ParentKind']; //显示完整的标题
Case i of
1: LabTitle1.Hint:=STR2;
2: LabTitle2.Hint:=STR2;
3: LabTitle3.Hint:=STR2;
4: LabTitle4.Hint:=STR2;
5: LabTitle5.Hint:=STR2;
6: LabTitle6.Hint:=STR2;
7: LabTitle7.Hint:=STR2;
8: LabTitle8.Hint:=STR2;
end;
end;
end;end;
procedure TFrmNumeralTV.ShowChanNum; ////窗体显示时,频道分类标题同步显示
var
i:integer;
str1,str2:string;
begin
for i:=1 to 8 do
begin
With ADOQueCha do
begin
close;
SQL.Clear;
SQL.Add('select ParentKind from Chanel where ParentKindID=:ID');
parameters.ParamByName('ID').Value:=i;
open; STR1:=LEFTSTR(ADOQueChA.FieldValues['ParentKind'],3); //出现错误提示:不能把NULL转换为字符(STRING)
Case i of
1: LabTitle1.Caption:=STR1;
2: LabTitle2.Caption:=STR1;
3: LabTitle3.Caption:=STR1;
4: LabTitle4.Caption:=STR1;
5: LabTitle5.Caption:=STR1;
6: LabTitle6.Caption:=STR1;
7: LabTitle7.Caption:=STR1;
8: LabTitle8.Caption:=STR1;
end;
STR2:=ADOQueChA.FieldValues['ParentKind']; //显示完整的标题
Case i of
1: LabTitle1.Hint:=STR2;
2: LabTitle2.Hint:=STR2;
3: LabTitle3.Hint:=STR2;
4: LabTitle4.Hint:=STR2;
5: LabTitle5.Hint:=STR2;
6: LabTitle6.Hint:=STR2;
7: LabTitle7.Hint:=STR2;
8: LabTitle8.Hint:=STR2;
end;
end;
end;end;
解决方案 »
- 跪求组件
- 帮忙用delphi写个读取RS232接口数据,并存入指定数据库的程序
- 怎样动态调整 Media Play 控件的显示大小?
- 各位帮忙,怎样在输出float数据时加上千分位,我用formatfloat('#,###.##',12345676.77)为什么不行?谢谢!
- 高分请教: 怎样用BDE Administrator连上MS SQL Server2000???
- 在线等待,截取字符串问题,
- 问一个很菜的问题,关于控件的使用!!
- vfp怎么连接数据库上的sqlserver数据库? odbc怎么设置?
- 我想请问哪里有rxlib for delphi5.0的控件下载?
- 求救: 用没有人用过solaris unix 下的interbase 6?
- 急!我向窗体中输入数据后点保存,数据保存了,但是再次点击窗体时页面还是显示刚才输入数据,怎样刷新页面呢
- 关于10个Edit控件删除的问题!
STR1:=LEFTSTR(ADOQueChA.FieldByName('ParentKind').AsString,3);因为我没遇到过这个问题,而我一直是这样取值的,所以我觉得这样应该能解决楼主的问题。
Str1 := ''
else
Str1 := LeftStr(ADOQueChA.FieldValues['ParentKind'], 3);
Str1:= ADOQueChA.FieldValues['ParentKind']
if Trim(Str1)< 3 then Continue;