| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3276 人关注过本帖
标题:vfp如何列出Access数据库结构
取消只看楼主 加入收藏
yll148
Rank: 2
等 级:论坛游民
威 望:3
帖 子:268
专家分:15
注 册:2012-7-3
结帖率:87.5%
收藏
已结贴  问题点数:10 回复次数:6 
vfp如何列出Access数据库结构
请各位高手指导vfp如何列出Access数据库结构的方法
搜索更多相关主题的帖子: 数据库 如何 
2016-11-13 08:59
yll148
Rank: 2
等 级:论坛游民
威 望:3
帖 子:268
专家分:15
注 册:2012-7-3
收藏
得分:0 
直接读取access数据库结构,有什么办法列出小数位数?请各位高手指点谢谢!
2016-11-15 21:24
yll148
Rank: 2
等 级:论坛游民
威 望:3
帖 子:268
专家分:15
注 册:2012-7-3
收藏
得分:0 
谢谢您的指点,之前我看过一个例子但没有成功,请您看看他使用的方法。
图片附件: 游客没有浏览图片的权限,请 登录注册
2016-11-16 21:08
yll148
Rank: 2
等 级:论坛游民
威 望:3
帖 子:268
专家分:15
注 册:2012-7-3
收藏
得分:0 
    set safety off
     local oo,lcStr,lcMdbFile,i,x,lnFields,lcTableName,lnFieldtype,lcCurdir
     lcCurdir = sys(5) + curdir()
     lcNowdir = getdir()
     cd (lcNowdir)
     oo = NEWOBJECT('Access.Application')
     oo.AutomationSecurity = 1
     oo.UserControl           = .F.
     lcMdbFile = getFile('mdb')
     if not empty(lcMDBFile)
        oo.OpenCurrentDatabase(lcMDBFile)
         lnTables = oo.CurrentDb.TableDefs.Count
         for i = 5 to lnTables - 1
              lcStr = ''
              lnFields = oo.CurrentDb.TableDefs(i).fields.count
              *lcTableName = JUSTSTEM(lcMDBFile) + '_' + oo.CurrentDb.TableDefs(i).Name
              lcTableName = oo.CurrentDb.TableDefs(i).Name
              *use
              if i = 5
                   create Table blank (字段名 char(9),类型 char(10),宽度 char(2),小数位 char(4),标题 char(24),对应字段 char(20),表名 char(10))
              endif
              for x = 0 to lnFields - 1
                   append blank
                   lnFieldType = oo.CurrentDb.TableDefs(i).Fields(x).type
                   do case
                   case lnFieldType  = 10
                       lcType = '字符型'
                   case lnFieldType  = 5
                       lcType = '货币型'
                   case lnFieldType  = 8
                       lcType = '日期时间型'
                   case lnFieldType  = 3
                       lcType = '整型'
                   case lnFieldType  = 6
                       lcType = '单精度型'
                   otherwise
                       lcType = ltrim(str(oo.CurrentDb.TableDefs(i).Fields(x).type))
                   endcase
                   replace 字段名 with oo.CurrentDb.TableDefs(i).Fields(x).name
                   replace 类型   with lcType
                   replace 宽度   with ltrim(str(oo.CurrentDb.TableDefs(i).Fields(x).size))
                   if inlist(lnFieldType,3,5,6)
                       lnValue = oo.Currentdb.TableDefs(i).Fields(x).Properties('DecimalPlaces').Value
                       replace 小数位 with icase(lnValue = 255,'自动',alltrim(str(lnValue)))
                   endif
                   replace 标题 with oo.CurrentDb.TableDefs(i).Fields(x).Properties('caption').value
                   replace 表名 with lcTableName
              endfor
         endfor
     endif
     oo.CloseCurrentDatabase()
     oo = null
     cd (lcCurdir)
Properties提示这个函数无效,不知道是怎么回事?请同仁指点。
 
2016-11-17 20:31
yll148
Rank: 2
等 级:论坛游民
威 望:3
帖 子:268
专家分:15
注 册:2012-7-3
收藏
得分:0 
那lnValue = oo.Currentdb.TableDefs(i).Fields(x).Properties('DecimalPlaces').Value这个可以吗?
2016-11-18 11:47
yll148
Rank: 2
等 级:论坛游民
威 望:3
帖 子:268
专家分:15
注 册:2012-7-3
收藏
得分:0 
但是Properties('DecimalPlaces')这个DecimalPlaces对象显示不存在,用其他也没有成功。
2016-11-18 15:23
yll148
Rank: 2
等 级:论坛游民
威 望:3
帖 子:268
专家分:15
注 册:2012-7-3
收藏
得分:0 
可以了,多谢指点。
2016-11-19 03:03
快速回复:vfp如何列出Access数据库结构
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012523 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved