DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: cuiqingbo
今日帖子: 20
在线用户: 12
导航: 论坛 -> 数据库专区 斑竹:liumazi,waterstone  
作者:
男 huo_v_wu (勇敢的螳螂) ★☆☆☆☆ -
盒子活跃会员
2022/6/22 22:43:48
标题:
关于生成DBF表的字段太长的问题 浏览:2106
加入我的收藏
楼主: 我现在需要用程序生成一个dbf的表,但这个表有120个字段,我发现只要到了40个字典,就会报错delphi record size is too big for table table dose not exist
请问下这个问题该如何解决?
function DataExports(NZYH: string; NDataset: tadodataset): Boolean; //雕龙病案首页医保导出
var

  NConStr: string;
  NPath: string;
  NStr: string;
  BaseName: string;
  TableName: string;
  table: Ttable;
begin
  try
    table := TTable.Create(nil);
    table.Close;
    table.Active := false;
    table.Exclusive := true;
    table.TableName := NZYH;
    table.TableType := ttFOXPRO;
    with table.FieldDefs do
    begin
      Clear;
      with AddFieldDef do
      begin
        Name := 'USERID_';
        DataType := ftString;
        Size := 60;
      end;

      with AddFieldDef do
      begin
        Name := 'USERNAME';
        DataType := ftString;
        Size := 60;
      end;
.........
创建的字段超过40个就会报错
----------------------------------------------
-敢于学习,谦虚学习,鼓励批评!!
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/6/22 23:01:16
1楼: Table main = MyTableMainWith120Fields

MyTableMainWith120Fields ... MainFieldID = the main field

Solution: Divide in sub-tables and use "Master-Details" technic!

Tables
MyTableMainWith120Fields ... < 40  fields
...Field: MainFieldID
...

SubTable001 ... <40 fields
...Field: Sub001FieldID  
...Field: MainFieldID  >  the relationship Master-Details
...

SubTable002 ... <40 fields
...Field: Sub001FieldID  
...Field: MainFieldID  >  the relationship Master-Details
...

etc....
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 huo_v_wu (勇敢的螳螂) ★☆☆☆☆ -
盒子活跃会员
2022/6/23 9:08:36
2楼: 没看懂这是什么意思
----------------------------------------------
-敢于学习,谦虚学习,鼓励批评!!
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/6/23 13:43:31
3楼: 我已经在其他时间回复了你的帖子!
DBF 文件具有您不能超过的技术限制!

DBase 4 (DBF 4) 每个表最多可以有 255 个字段。
如果您无法创建这 255 个字段,那么您可能做错了什么:

例如:
-- 每条记录的所有字段加起来超过 4,000 字节!


https://www.dbase.com/Knowledgebase/faq/dBASE_Limits_FAQ.html


DBASE Limits

Description
Open dBASE tables per system (16 Bit) = 256 tables-files
Open dBASE tables per system (BDE 3.0 - 4.0, 32 Bit) = 350 tables-files
Open dBASE tables per system (BDE 4.01, 32 Bit) = 512 tables-files
Record locks on one dBASE table (16 and 32 Bit) = 100 records
Records in transactions on a dBASE table (32 Bit) = 100 transactions
Records in a table = 1 Billion  = 1.000.000.000
Bytes in .DBF (Table) file = 2 Billion = 2.000.000.000
Size in bytes per record (dBASE 4) = 4.000
Size in bytes per record (dBASE for Windows) = 32.767
----------
Number of fields per table (dBASE 4) = 255 fields
Number of fields per table (dBASE for Windows) = 1024 fields
----------
Number of index tags per .MDX file = 47
Size of character fields = 254 chars
Open master indexes (.MDX) per table = 10
Key expression length in characters = 220 chars

----------
如果您愿意,可以使用“主 - 详细信息”技术创建表

在哪里:
Master = 将是具有主要字段的表,以与“详细信息”表建立关系

Details = 将是包含其余记录数据的表。

例如:

主表:PERSON = 人
idPerson = integer   == 29     <---- 
Name = 30 characters == Huo V Wu


明细表:PERSON_DOCS = 人员文件
id = integer  1
idPerson = integer   == 29   .....  table "PERSON"  <----
Driver_Card = string == 123.456.789-0
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 huo_v_wu (勇敢的螳螂) ★☆☆☆☆ -
盒子活跃会员
2022/6/23 16:37:03
4楼: 只能允许一个表 一共有109个字段 导出格式需要是dbf 我该怎么处理 谢谢老师
----------------------------------------------
-敢于学习,谦虚学习,鼓励批评!!
作者:
男 pcplayer (pcplayer) ★☆☆☆☆ -
普通会员
2022/6/23 21:25:56
5楼: 3楼都说了:
【DBase 4 (DBF 4) 每个表最多可以有 255 个字段。
如果您无法创建这 255 个字段,那么您可能做错了什么:

例如:
-- 每条记录的所有字段加起来超过 4,000 字节!】


这也是之前我在你的另外一个帖子里面说的,字段大小的问题。
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/6/23 22:17:59
6楼: @huo_v_wu

Upload a "zip" with your code complete for analise!
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 huo_v_wu (勇敢的螳螂) ★☆☆☆☆ -
盒子活跃会员
2022/6/24 13:16:17
7楼: 目前只有109个字段 为什么还是报错呢?
----------------------------------------------
-敢于学习,谦虚学习,鼓励批评!!
作者:
男 lsu (lsu) ★☆☆☆☆ -
普通会员
2022/6/24 13:56:24
8楼: 好像总的记录累计长度也不能超过多长,N多年不用了记不清楚了。

https://sourceforge.net/projects/tdbf/files/TDbf%20Win32_Linux/TDbf%207.0.1/tdbf701.zip/download

https://sourceforge.net/projects/tdbf/files/TDbf%20documentation/TDbf%20documentation%201.1/tdbf.pdf/download

https://github.com/lynxnake/tDBF

https://github.com/fatehsetif/TDBF-For-Delphi-10.3-Rio



比系统自带的更好用。

网上也有很多人的修改版,做了很多扩充,支持更多字段,更长数据。当然就不符合DBF官方标准定义,但是更方便,自己程序中使用不与其它应用互通是没问题的。

这么多字段是不是没有做好主从表。
----------------------------------------------
-
作者:
男 hbdjlwb1 (hbdjlwb1) ▲▲△△△ -
普通会员
2023/1/30 14:40:47
9楼: 先按字段要求建一个空DBF,然后循环插入到DBF就OK。。我也是才做的
----------------------------------------------
-
作者:
男 bluestorm8 (bluestorm) ▲▲△△△ -
普通会员
2023/1/30 15:05:05
10楼: BDE是古董级的东西了,而且据说用BDE来修改dbf是有bug的.

可以用Apollo VCL代替, 性能也好锝多:
Apollo 7.3 完整源代码 D7-XE3
http://bbs.2ccc.com/topic.asp?topicid=460626
----------------------------------------------
-
作者:
男 bluestorm8 (bluestorm) ▲▲△△△ -
普通会员
2023/1/30 16:46:08
11楼: 用apollo vcl测试了一下, 创建200个长度为60的字段都没有问题:

procedure TForm1.Button1Click(Sender: TObject);
var
  I, N: Integer;
begin
  with Table do
  begin
    DatabaseName := 'D:\Test';
    TableName := 'Test.dbf';
    TableType := ttSXFOX;
    DeleteFile(DatabaseName + '\' + TableName);
    DeleteFile(DatabaseName + '\' + ChangeFileExt(TableName, 'fpt'));
    N := 200;
    if not CreateNew(DatabaseName + '\' + TableName, SDEFOX, N) then
    begin
      ShowMessage( 'Create failed' );
      Exit;
    end;
    {CreateField('fchar', 'C', 25, 0);
    CreateField('fnum' , 'N', 10, 2);
    CreateField('flog' , 'L',  1, 0);
    CreateField('fdate', 'D',  8, 0);
    CreateField('fmemo', 'M', 10, 0);}
    for I := 1 to N do
    begin
      CreateField('F'+I.ToString, 'C', 60, 0);
    end;
    if not CreateExec then
    begin
      ShowMessage( 'Create failed' );
      Exit;
    end;
    Open;
  end;
end;
----------------------------------------------
-
作者:
男 powerpcer (大强) ★☆☆☆☆ -
禁用账号
2023/1/30 17:20:46
12楼: ……
被禁用帐号,帖子内容自动屏蔽!
……

----------------------------------------------
呆湾傻冒
作者:
男 lcjclj (lcj) ★☆☆☆☆ -
盒子活跃会员
2023/1/31 5:09:53
13楼: 可以考虑一下用TDBF控件:

https://sourceforge.net/projects/tdbf/files/TDbf%20Win32_Linux/

如果可以实在不行,可以考虑用CVS格式,基本上EXCEL都可以打开。就是你需要手写数据而已,比DBF更方便。
----------------------------------------------
-
作者:
男 bluestorm8 (bluestorm) ▲▲△△△ -
普通会员
2023/1/31 9:05:53
14楼: @powerpcer 可以在这里下载:
此帖子包含附件:bluestorm8_2023131952.rar 大小:8.45M
----------------------------------------------
-
作者:
男 bluestorm8 (bluestorm) ▲▲△△△ -
普通会员
2023/1/31 9:21:28
15楼: @lcjclj 本人没有用过TDBF, 想请教一下这个组件用于长时间读写dbf文件是否可靠、稳定?
----------------------------------------------
-
作者:
男 powerpcer (大强) ★☆☆☆☆ -
禁用账号
2023/1/31 9:50:00
16楼: ……
被禁用帐号,帖子内容自动屏蔽!
……

----------------------------------------------
呆湾傻冒
作者:
男 1111111113 (1111111113) ▲△△△△ -
普通会员
2023/1/31 11:03:44
17楼: function FtsClose( FHandle : Integer ): Integer; stdcall; external 'FTS32.DLL';

https://github.com/search?l=C&q=DBase&type=Repositories

https://github.com/paule32/dBASE_BDE
----------------------------------------------
-
作者:
男 bluestorm8 (bluestorm) ▲▲△△△ -
普通会员
2023/1/31 13:07:40
18楼: @powerpcer 我没有full source版,不过买正版的的话应该可以选择购买full sourcede(Dll的源代码),不过价格肯定就贵了.
----------------------------------------------
-
作者:
男 powerpcer (大强) ★☆☆☆☆ -
禁用账号
2023/1/31 16:49:26
19楼: ……
被禁用帐号,帖子内容自动屏蔽!
……

----------------------------------------------
呆湾傻冒
作者:
男 lcjclj (lcj) ★☆☆☆☆ -
盒子活跃会员
2023/1/31 22:53:22
20楼: To: bluestorm8 (bluestorm)
很多年前我做过一个小工具用来导出DBF数据,效果挺好的。基本上能安全有效地处理不同版本的DBF。

你可以看看我附上的图片。
此帖子包含附件:
JPEG 图像
大小:77.8K
----------------------------------------------
-
作者:
男 powerpcer (大强) ★☆☆☆☆ -
禁用账号
2023/2/1 0:32:47
21楼: ……
被禁用帐号,帖子内容自动屏蔽!
……

----------------------------------------------
呆湾傻冒
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2023/2/1 11:04:03
22楼: https://sourceforge.net/p/tdbf/code/HEAD/tree/trunk/
看日期2023
还在更新呢。
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 powerpcer (大强) ★☆☆☆☆ -
禁用账号
2023/2/1 12:54:08
23楼: ……
被禁用帐号,帖子内容自动屏蔽!
……

----------------------------------------------
呆湾傻冒
作者:
男 bluestorm8 (bluestorm) ▲▲△△△ -
普通会员
2023/2/1 12:55:43
23楼: 我担心的不只是是编译器之类的错误, 我这里有一个读写dbf的老程序,是别的公司写的,工作一段时间后,dbf表就会写坏,由于没有这个程序的源代码,因此搞不清楚出错原因,更无法修改程序.
----------------------------------------------
-
作者:
男 bluestorm8 (bluestorm) ▲▲△△△ -
普通会员
2023/2/1 12:59:59
24楼: 如果要求高可靠性的话, 我觉得apollo vcl会比较好一点, 毕竟它时商业公司的产品,只是要带DLL比较麻烦,而且DLL的没有源代码有一定的风险..
----------------------------------------------
-
作者:
男 powerpcer (大强) ★☆☆☆☆ -
禁用账号
2023/2/1 17:27:15
25楼: ……
被禁用帐号,帖子内容自动屏蔽!
……

----------------------------------------------
呆湾傻冒
作者:
男 bluestorm8 (bluestorm) ▲▲△△△ -
普通会员
2023/2/1 17:41:10
26楼: 那里面没有dll的源代码, 只有调用这些dll的源代码.
Dll的源代码估计是用C语言写的.
----------------------------------------------
-
作者:
男 powerpcer (大强) ★☆☆☆☆ -
禁用账号
2023/2/1 18:10:57
27楼: ……
被禁用帐号,帖子内容自动屏蔽!
……

----------------------------------------------
呆湾傻冒
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2023/2/2 11:08:52
28楼: https://pecl.php.net/package/dbase

https://github.com/quentindemetz/libdbf
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2023/2/2 11:18:29
29楼: The CodeBase(tm) module source code supports several variants of DBF files including the original dBase IV versions, Clipper versions, FoxPro 2.x versions, and Visual FoxPro versions. However, the c4dll.dll version supplied in this distribution was compiled for Visual FoxPro compatibility only. If you need support for Clipper or dBase IV compatibility you can either build the c4dll.dll from the source or contact MPSystemsServices to request the maintainer to do this for you (when he has time).
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2023/2/2 11:19:58
30楼: https://github.com/mobigroup/sqlite3-dbf
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2023/2/2 11:23:28
31楼: ...中文的。。。。。。https://github.com/xumenger/cDBF
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2023/2/2 11:24:54
32楼: https://github.com/eaglebh/dbf2csv
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2023/2/2 11:25:53
33楼: http://shapelib.maptools.org/dbf_api.html
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 keymark (嬲) ▲▲▲△△ -
普通会员
2023/2/2 11:30:16
34楼: https://github.com/seca-rca/fastdbf
----------------------------------------------
[alias]  co = clone --recurse-submodules  up = submodule update --init --recursiveupd = pullinfo = statusrest = reset --hard懒鬼提速https://www.cctry.com/>http://qalculate.github.io/downloads.htmlhttps://www.cctry.com/
作者:
男 powerpcer (大强) ★☆☆☆☆ -
禁用账号
2023/2/2 12:01:29
35楼: ……
被禁用帐号,帖子内容自动屏蔽!
……

----------------------------------------------
呆湾傻冒
作者:
男 powerpcer (大强) ★☆☆☆☆ -
禁用账号
2023/2/2 14:06:54
36楼: ……
被禁用帐号,帖子内容自动屏蔽!
……

----------------------------------------------
呆湾傻冒
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行1031.25毫秒 RSS