Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Weirdest tableupdate problem !
Message
De
13/06/2007 23:22:15
Yh Yau
Ingenuity Microsystems Sdn Bhd
Kuala Lumpur, Malaisie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01231912
Message ID:
01232844
Vues:
13
Dear Boris,
Here's the source:
Basically, the first 2 steps are used to populate the primary keys of the parent and child tables and a table called icount with a document type is used to track the running numbers.
The problem happens on the 3rd line after the begin transaction
in both the saveheader and savedetail methods, it basically contains the following:-
select fheader or fdetail
llflag=tableupdate(1,.f.,"fheader")
We put a brow window before and after the savedetail method and the problems described earlier happened there.

Hope you can assist
Thanks
Yau
if thisform.frm_mode="A"
	headtype=thisform.mdoch
	=sqlexec(posqlconn,"select current_no from icount where doc_type='"+ headtype +"' ","c_currhkey")
	=sqlexec(posqlconn,"update icount set current_no=current_no+1 WHERE DOC_TYPE='"+ headtype +"'")
	=sqlcommit(posqlconn)
	SELECT c_currhkey
		replace fheader.hkey with c_currhkey.current_no+1
		thisform.m_filldetail(c_currhkey.current_no+1)
		IF USED('c_currhkey')
			USE IN c_currhkey
		endif	
endif

if thisform.frm_mode="A"
	m.dettype=thisform.mdocd
	sele fdetail
	go top
	do while !eof()
		=SQLEXEC(posqlconn,"select a.doc_type, a.current_no from icount a where a.doc_type='ND'",  “c_currdkey")
		SELECT c_currdkey
		=sqlexec(posqlconn,"update icount set icount.current_no=icount.current_no+1 where icount.doc_type='"+ALLTRIM(m.dettype)+"'")
		=sqlcommit(posqlconn)
			replace fdetail.dkey with c_currdkey.current_no+1
			IF USED('c_currdkey')
				USE IN c_currdkey
			endif	
		SELE FDETAIL
		SKIP 
	enddo
endif


wait window "Processing..." nowait
do case
	case thisform.frm_mode="A"
		=SQLSETPROP(posqlconn, 'Transactions', 2)  && Manual transactions	
		BEGIN TRANSACTION 	
		IF thisform.m_saveheader() 
			select fheader			
			if (thisform.m_savedetail())
				if thisform.m_saveother()  && Detail file is updated
					if thisform.m_savestk()			&& Fire posting trigger
						if thisform.m_savegl()
							IF sqlcommit(posqlconn)<= 0
								=SQLROLLBACK(posqlconn)
								ROLLBACK 			
								thisform.o_busrules.m_messbox("Cannot Commit Transaction!")
							ELSE 							
								end transaction  
								llupdate=.t.
							ENDIF 
						ELSE 
							=SQLROLLBACK(posqlconn)
							ROLLBACK
							thisform.o_busrules.m_messbox("Cannot Update GL!")							
						ENDIF 		
					ELSE 
						=SQLROLLBACK(posqlconn)
						rollback
						thisform.o_busrules.m_messbox("Cannot Update Stock!")
					ENDIF 	 	
				ELSE 
					=SQLROLLBACK(posqlconn)
					rollback
					thisform.o_busrules.m_messbox("Cannot Update Postings!")
				ENDIF 
			ELSE
				=SQLROLLBACK(posqlconn)
				rollback
				thisform.o_busrules.m_messbox("Cannot Update Detail File!")
			ENDIF 
		ELSE
			=SQLROLLBACK(posqlconn)
			ROLLBACK
			thisform.o_busrules.m_messbox("Cannot Update Header File!")					
		ENDIF
		
		IF llupdate
			thisform.lockscreen=.f.
			wait clear
			thisform.o_busrules.m_messbox(thisform.name+" "+"Number ";
			+allTRIM(thisform.firstfield.value)+" Saved!",64)
			thisform.m_printdoc()
		ELSE 
			thisform.o_busrules.m_messbox("Unable to save Transaction! Try again later!") 
			thisform.m_reverttable							
		ENDIF  
		WAIT CLEAR
		thisform.lockscreen=.t.	
		thisform.lcreckey=0
		thisform.frm_doc_no=" "
		append blank in fheader
		thisform.lockscreen=.f.
		thisform.refresh		
		if !thisform.autonum
			thisform.firstfield.setfocus 
		else
			thisform.secondfield.setfocus
		endif	
		return
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform