也许你早已厌倦了做Delphi组件时的声明,下面是我写的小视图,也许能帮上你的忙。
创建一个视图:如下
CREATE VIEW dbo.TP
AS
SELECT Names = 'property ' + syscolumns.name + ':', 
      theType = CASE WHEN systypes.name = 'Varchar' THEN 'String' 
                     when systypes.name = 'int' THEN 'integer'
                     when systypes.name = 'text'then 'String'
                     when systypes.name = 'DateTime' then 'TDateTime'
                ELSE systypes.name
       END, other = ' read Get' + syscolumns.Name + ';'
FROM syscolumns LEFT JOIN
      systypes ON syscolumns.xtype = systypes.xtype
WHERE id IN
          (SELECT ID
         FROM sysobjects
         WHERE Name = 'T_SUBMIT')
--Name写入你想要的表。
在查询分析器里写入:
select Names+theType+other from TP
F5结果:
    property CorpName:String read GetCorpName;
    property SubmitID:integer read GetSubmitID;
    property SubmitName:String read GetSubmitName;
    property SubmitInputName:String read GetSubmitInputName;
    property Title:String read GetTitle;
    property Name:String read GetName;
    property Country:String read GetCountry;
    property BelongCorp:String read GetBelongCorp;
    property Province:String read GetProvince;
    property Tel:String read GetTel;
    property Fax:String read GetFax;
    property Email:String read GetEmail;
    property Addr:String read GetAddr;
    property ReceiptCountry:String read GetReceiptCountry;
    property DeliveryCountry:String read GetDeliveryCountry;

解决方案 »

  1.   

    hehe 大早上的,辛苦了,这个对我来说有点启示作用,谢谢了
      

  2.   

    to : fengjn(小枫)
     我应该补充一下,我做的多数是数据层,也就是数据实体类。
     通过该类来进行数据操作,而在创建实体类时很多与数据库中的表打教到,
     我做这段,是避免了你一个一个到数据库中去对应字段名与数据类型。
     和繁琐的Delphi属性声明。
    to; imageonline(不交房租) 
     他说对了,只有编写对应表的实体类时,才能体会这个视图的用处。
      

  3.   

    很好,高手,我正在研究多层数据库,特别是数据实体类,我特别感兴趣,能详细介绍一下或给我一些资料么,万分感谢!!谢谢!谢谢!谢谢!谢谢   [email protected]
      

  4.   

    谢谢大家的关心。留下联系方式:
    MSN:[email protected]