************************	inceput conecteaza ***************************
Procedure conecteaza
	Lparameters tcHost, tcUser, tcPassword

	gnConnHandle = SQLConnect(tcHost, tcUser, tcPassword)
	If gnConnHandle < 1
		Aerror(laEroare)
		Messagebox(laEroare(2))
	Endif

	Return gnConnHandle
Endproc

**************************** inceput executaSql ***************************
Function executaSql
	Lparameters cmdSql, crsName, tlShowErr
	Local lnSucces

	lnSucces = -1

	If Pcount() < 2 And !m.tlShowErr
		crsName=""
	Endif

	If gnConnHandle > 0
		lnSucces=SQLExec(gnConnHandle,cmdSql,crsName)

		If lnSucces < 0 And m.tlShowErr
			Aerror(laEroare)
			eroaresql(@laEroare,cmdSql)
		Endif
	Endif

	Return lnSucces
Endfunc

*************************	inceput deconecteaza ************************
Function  deconecteaza
	*Lparameters lnConn
	Local lnSucces

	lnSucces = -1
	If lnConn > 0
		lnSucces = SQLDisconnect(gnConnHandle)
	Endif

	Return lnSucces
Endfunc

*******************************	inceput eroareSql **********************************
Procedure eroaresql
	Lparameters laErr, lcsql
	
	EXTERNAL ARRAY laErr
	
	Local lcMesaj

	lcMesaj = [Eroare # : ] + Alltrim(Str(laErr(1))) + crlf + ;
		[Mesajul : ] + laErr(2) + ;
		IIF(!Empty(laErr(3)), [Eroare OLE : ] + laErr(3) ,[]) + ;
		[Aplicatie : ] + laErr(4) + ;
		IIF(Pcount() = 2, crlf + lcsql, [])
	Messagebox(lcMesaj,0+16)

Endproc
