Hello,
Is there a function in FWH that creates a unique ID? I need to created a unique ID every time logs in to our system.
Thank you!
//---------------------
Static Func _GenTripsEid()
LOCAL nRAND, cRAND, oRs, cSQL, oERR
cSQL := "SELECT TRIPSEID from TRIPS"
oRs := TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType := 1 // opendkeyset
oRs:CursorLocation := 3 // local cache
oRs:LockType := 3 // lockoportunistic
TRY
oRs:Open( cSQL,oCn )
CATCH oErr
MsgInfo( "Error in Opening TRIPS table to create TripsEid" )
RETURN("BOGUS")
END TRY
cRAND := 'BOGUS'
DO WHILE .T.
nRAND := nRANDOM(10000000000000000)
// 1 is reserved and 0 is a null key //
IF nRAND = 1 .or. nRAND = 0 .or. nRAND = NIL
LOOP
ENDIF
cRAND := STR(nRAND,17)
IF oRs:eof
ELSE
oRs:MoveFirst()
oRs:Find("tripseid = '"+cRAND+"'" )
ENDIF
IF oRs:eof
EXIT
ELSE
LOOP
ENDIF
EXIT
ENDDO
oRs:CLose()
RETURN( cRAND )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot], jmartial and 39 guests