当前位置:主页>delphi教程/企业管理软件> 文章内容

发布时间:2010-01-21 | QQ免费站
1楼: 数据库为sql 2000

2楼: 如题。

3楼: 如果我理解没错的话,你是想取字段说明内容吧, 第一步:Uses中加入ComObj、ADOX_TLB;   {参考以下步骤: sdhxdjw (2002-11-28 18:17) 可以利用ADOX对象! 开发平台或客户端需要安装MDAC 2.1数据库引擎,你可以从微软公司http://www.microsoft.com/data下载,也可以在安装IE5.0中选择定制安装“动态数据绑定”选项。   在Delphi IDE中选择菜单Project\Import Type Library,出现Import Type Library对话框,选择“Microsoft ADO Ext. 2.x for DDL and Security”, 将Class Name中TTable改为TADOXTable(因为TTable组件在Delphi中已经存在并注册);选择“Microsof Jet and Replication Object 2.x Library”。 然后单击“Install”安装,便在Delphi的Imports目录下生成ADOX_TLB.pas和JRO_TLB.pas两个文件。在Unit文件的Uses中加入ComObj、ADOX_TLB  } 第二步:使用ADOX对象连接数据库; 第三步:取得字段说明内容;  { with Column do  // Column 是个_Column对象 begin for i := Properties.Count - 1 downto 0 do if Properties[i].Name = ‘Description‘ then begin Result := Result + Properties[i].Value; // Properties[i].Value 就是你要的结果 break; end; end; } 试一下,用这个方法是否能把默认值给读出来? 字串8

4楼: 默认值 字串9

5楼: 我取出了 Properties[i].Name 的所有值: *Column Level Collation Name*Unique*Primary Key*Nullable*Fixed Length*Default*Autoincrement// *号是我加的为了区分 没有发现类似‘Description‘ 的,呵呵,因为我想取得默认值而已,就改了 if Properties[i].Name = ‘Default‘ then  但跟踪运行到 Result := Result + Properties[i].Value; 出现错误,提示 --------------------------- Debugger Exception Notification --------------------------- Project Project1.exe raised exception class EOleException with message ‘对象或提供者不能执行所需的操作。‘. Process stopped. Use Step or Run to continue. --------------------------- OK Help ---------------------------
字串4

6楼: 是不是要看數據庫裡面字段的默認值? SELECT text FROM syscomments WHERE id in ( select id from sysobjects where parent_obj in ( select id from syscolumns where id in ( select id from sysobjects where name=‘tablename‘) and name=‘fieldname‘ ) and xtype=‘D‘) tablename為表名,fieldname為字段名,得出的默認值是帶括號的 sql server 2000執行可以,別的不知道

字串5

7楼: if properties.item[i].Name = ‘Default‘ then //这样如何???
字串4

8楼: to victor_zh 谢谢,你那样解决是完全可以的,但我这里所求的不是用sql语句,只用adox取得字段信息。 to app2001:呵呵,还是有问题,不论字段是否有默认值,都出现 ‘对象或提供者不能执行所需的操作。‘. 字串7

9楼: 我的代码: adoxCatalog: _Catalog; adoxTable: _Table; adoxColumns: Columns; 窗体创建时: adoxcatalog := cocatalog.Create; 打开表时 : con1.GetTableNames(cbbTbl.Items, false); adoxcatalog.Set_ActiveConnection(con1.ConnectionObject); adoxtable := adoxcatalog.Tables[cbbTbl.ItemIndex + sysTblCount]; //系统表不显示 adoxcolumns := adoxtable.Columns; 然后 with adoxcolumns[colIndex] do begin for ipts := Properties.Count - 1 downto 0 do if properties.item[ipts].Name = ‘Default‘ then begin sResult + Properties[ipts].Value; break; end; end; ShowMessage(sResult);
字串9

10楼: 怎么没人回答呢? 在线等啊。。。

字串1

11楼: 失望.. 字串3