xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

NetErr()

Determines if a database command has failed in network operation.

Syntax

NetErr( [<lNewStatus>] ) --> lIsNetworkError

Arguments

<lNewStatus>
An optional logical value that sets the global status for errors which may occur with database operations in a network.

Return

The function returns .T. (true) if a database could not be opened or a new record could not be created during concurrent access in a network. Otherwise, the return value is .F. (false).

Description

NetErr() is a function used to detect database errors that may occur with the commands USE, USE...EXCLUSIVE or APPEND BLANK when a database is concurrently accessed by multiple applications in a network. The function maintains a status variable indicating such errors. The status variable is set by xHarbour's default error handling system in following situations:

Possible NetErr() conditions
Failed commandDescription
USEUSE EXCLUSIVE is issued by another process
USE...EXCLUSIVEUSE or USE EXCLUSIVE is issued by another process
APPEND BLANKLastRec()+1 is locked with FLock() or Rlock() by another process

NetErr() returns .T. (true) if a database command failed due to these conditions.

Info

See also:APPEND BLANK, DbAppend(), DbRLock(), DbUseArea(), FLock(), NetName(), RLock(), USE
Category: Database functions , Network functions
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example illustrates the situations where NetErr() is used
// to detect possible database access errors in a network:

   PROCEDURE Main

      USE Customer ALIAS Cust NEW EXCLUSIVE
      IF .NOT. NetErr()
         INDEX ON CustID                    TO Cust01
         INDEX ON Upper(LastName+FirstName) TO Cust02
         USE
      ELSE
         ? "File cannot be opened exclusively"
      ENDIF

      USE Customer ALIAS Cust SHARED NEW
      IF .NOT. NetErr()
          SET INDEX TO Cust01, Cust02
      ELSE
         ? "File is exclusively used by another process"
      ENDIF

      IF Select( "Cust" ) > 0
         SELECT Cust
         APPEND BLANK
         IF .NOT. NetErr()
            REPLACE CustID WITH "X087"  , ;
                    Name   WITH "Miller"
         ELSE
            ? "Record is currently locked by another process"
         ENDIF
      ENDIF

   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe