fs.SetFieldType(ftString)不起作用

wq58 2004-12-16 08:49:57
var
Fs:TField;
begin
fs := TField.Create(nil);
fs.FieldName := 'Field1';
fs.DisplayLabel := 'NEWField';
fs.SetFieldType(ftString);
Query1.Fields.Add(fs);
ShowMessage(Query1.FindField('Field1').DisplayLabel);


其中fs.SetFieldType(ftString)好像不起作用,query.open时,抱错:unknown fieldtype
我用的是TOraQuery,连接Oracle数据库,请高人指点
...全文
101 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kevin_Lmx 2004-12-16
  • 打赏
  • 举报
回复
很遗憾,应该没有什么办法了。除非你自己实现SetFieldType。
wq58 2004-12-16
  • 打赏
  • 举报
回复
Kevin_Lmx(繁华阅尽) :
没办法加FieldType吗?
Kevin_Lmx 2004-12-16
  • 打赏
  • 举报
回复
试试这样子加:
Query1.FieldDefs.Add('Field1',ftString,200);
Kevin_Lmx 2004-12-16
  • 打赏
  • 举报
回复
我刚刚看了TField.SetFieldType这个方法,发现它只是一个虚方法。也就是说它其实是什么都不做的。在帮助中也提到:SetFieldType does nothing
----------------------------------------------------------------------------------------

procedure SetFieldType(Value: TFieldType);

Description

As implemented in TField, SetFieldType does nothing. Descendant classes override SetFieldType to set the DataType for the field component. SetFieldType is useful for derived classes that can support more than one underlying data type. For example, a TBlobField may support ftBlob, ftFmtMemo, ftParadoxOle, ftDBaseOle, or ftTypedBinary.
wq58 2004-12-16
  • 打赏
  • 举报
回复
Kevin_Lmx(繁华阅尽) :

不用TOraQuery,用TQuery也一样,请指点
wq58 2004-12-16
  • 打赏
  • 举报
回复
Kevin_Lmx(繁华阅尽) :

好像和ODAC关系不大,
var
Fs:TField;
V_DataType:TFieldType;
begin
fs := TField.Create(nil);
fs.FieldName := 'Field1';
fs.DisplayLabel := 'NEWField';
fs.SetFieldType(ftString);

V_DataType:=fs.DataType;--------跟踪显示为unknow,说明SetFieldType不成功

Query1.Fields.Add(fs);
ShowMessage(Query1.FindField('Field1').DisplayLabel);
才子鸣 2004-12-16
  • 打赏
  • 举报
回复
up
herman~~ 2004-12-16
  • 打赏
  • 举报
回复
帮顶
Kevin_Lmx 2004-12-16
  • 打赏
  • 举报
回复
上面那段东东好像是在下写的吧?很眼熟的说~
我这边没用ODAC这套控件。
你查查它的帮助,看看它对数据字段的定义吧
zwb666 2004-12-16
  • 打赏
  • 举报
回复
ding

5,930

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧