Help on creating dbf file

Post Reply
tsai8839
Posts: 22
Joined: Mon Jul 24, 2006 6:45 am

Help on creating dbf file

Post by tsai8839 »

Hi, all

When I try to open a .dbf file by USE(cFilename), I got an error message “Error DBFNTX/1012 Corruption detected”. This .dbf file was created by the following:

for n = 1 to Len( oLbx:aItems )
AAdd( aFields, _FieldInfo( AllTrim( oLbx:aItems[ n ] ) ) )
next
DbCreate( cDbfName, aFields )
MsgInfo( "DBF created!", "AllRight" )

static function _FieldInfo( cItem )
return { StrToken( cItem, 1 ),;
StrToken( cItem, 2 ),;
Val( StrToken( cItem, 3 ) ),;
Val( StrToken( cItem, 4 ) ) }

Any help would be much appreciated.
Regards,

Andy Tsai
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

It is hard to debug without knowing the contents of oLbx:aItems. Can you provide us with a small sample?
tsai8839
Posts: 22
Joined: Mon Jul 24, 2006 6:45 am

Post by tsai8839 »

Dear James,

The following sample may be helpful to debug.

static function AddField( oLbx, oGet, oBtnAdd, oBtnEdit,;
cName, cType, nLen, nDec, lEditing )

if Empty( cName )
MsgInfo( "I need a field name", "Sorry" )
else
if ! lEditing
oLbx:Add( xPadR( cName, 100 ) + Chr( 9 ) + cType + ;
xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ),;
oLbx:GetPos() )
else
oLbx:Modify( xPadR( cName, 100 ) + Chr( 9 ) + cType + ;
xPadL( Str( nLen, 3 ), 50 ) + xPadL( Str( nDec, 1 ), 20 ) )
oBtnAdd:SetText( "&Add" )
oBtnEdit:Enable()
lEditing = .f.
endif
cName = Space( 10 )
oGet:Refresh()
oGet:SetFocus( .t. )
endif

return nil
Regards,

Andy Tsai
zlatan24
Posts: 5
Joined: Thu Jul 02, 2009 6:46 am

Re: Help on creating dbf file

Post by zlatan24 »

This issue can be solved owing to repair .dbf. It owns all required opportunities for repairing data after various issues: power failures, viruses, hacker attacks. The tool has easy to use and simply interface due to any experienced users.
User avatar
Bayron
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re:

Post by Bayron »

oLbx:Modify( xPadR( cName, 100 ) + Chr( 9 ) + cType + ;
Maybe it has something to do with that you are including a Chr( 9 ) (Horizontal Tab) in this sentence???

Is that what you wanted to include or it was a Chr( 10 ) (Line Feed)
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
Post Reply