Page 1 of 1

Help on creating dbf file

PostPosted: Sat Jul 29, 2006 12:04 am
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.

PostPosted: Sat Jul 29, 2006 4:12 pm
by James Bott
It is hard to debug without knowing the contents of oLbx:aItems. Can you provide us with a small sample?

PostPosted: Sun Jul 30, 2006 11:53 pm
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

Re: Help on creating dbf file

PostPosted: Tue Sep 27, 2011 11:25 am
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.

Re:

PostPosted: Tue Sep 27, 2011 3:05 pm
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)