documento CHAR (10)
tipmov CHAR (2)
codfact CHAR (7)
codvend CHAR (7)
codcaj CHAR (2)
codcli CHAR (7)
fecha date
codprod CHAR (7)
descrip CHAR (60)
cantidad REAL
precio REAL
total REAL
User: postgres =
Key: = "dgs"
Refresh DCBrowse with SQL Express Demo
Re: Refresh DCBrowse with SQL Express Demo
Nolberto Paulino
Regards
Regards
Re: Refresh DCBrowse with SQL Express Demo
This is too big of a project for me to help you with.
I would need to create a PostGreSql database.
It could take hours just to get it running and then I still don't know what problem you are having.
I would need to create a PostGreSql database.
It could take hours just to get it running and then I still don't know what problem you are having.
The eXpress train is coming - and it has more cars.
Re: Refresh DCBrowse with SQL Express Demo
Hello Paulino,
insert a oCursor:updaterow() after adding or changing your data and check if oBrowse is really correct assigned. Try to ACTION {|| InsertarRegistro(GetList,aApp ),oBrowse:refreshall() } or ACTION {|| InsertarRegistro(GetList,aApp ),dc_getrefresh(oBrowse) }
regards
Rudolf
insert a oCursor:updaterow() after adding or changing your data and check if oBrowse is really correct assigned. Try to ACTION {|| InsertarRegistro(GetList,aApp ),oBrowse:refreshall() } or ACTION {|| InsertarRegistro(GetList,aApp ),dc_getrefresh(oBrowse) }
regards
Rudolf
Re: Refresh DCBrowse with SQL Express Demo
Hello,
attached a handy litte function that makes it easier to insert and update with checking and existing key. You can adapt it for your needs.
regards
Rudolf
attached a handy litte function that makes it easier to insert and update with checking and existing key. You can adapt it for your needs.
regards
Rudolf
Code: Select all
aFields := {}
aadd(aFields,{"field1","mydb->field1",NIL})
aadd(aFields,{"field2","mydb->field2",NIL})
updaterec(oConn,aFields,"ID",mydb->id,"mytable",@cError,.t.)
...
function updaterec(oConn,aFields,cKeyValue,cKeyField,cTable,cError,lDebug)
******************************************************************
local oStmt,i,oCursor,cSQL,aData := {},cUpdate := "",cVars := "(",cValues := "(",cValue,nResult,lOk := .t.,lIsKey := .f.,cLog := ".\log\lastsql.log",lUpdate := .f.,cWhere := ""
default lDebug to .f.
cError := ""
if lDebug
dcqdebugoff "start creating SQL statment"
dcqdebugoff "Key field:" + var2char(cKeyField)
dcqdebugoff "Key value:" + var2char(cKeyValue)
dcqdebugoff "table:" + cTable
endif
*------------------------- check if exists -----------------------------------
if valtype(cKeyValue) = "N"
cWhere := ntrim(cKeyValue)
elseif valtype(cKeyValue) = "C"
cWhere := "'" + alltrim(cKeyValue) + "'"
elseif valtype(cKeyValue) = "D"
cWhere := sql_date(cKeyValue)
else
// problem
endif
cSQL := "SELECT * FROM " + cTable + " WHERE " + cTable + "." + cKeyField + " = " + cWhere + ";"
if lDebug
dcqdebugoff "check: " + cSQL
prot("check: " + cSQL ,cLog)
endif
nResult := oConn:execute(cSQL)
if nResult = 0// insert
if lDebug
dcqdebugoff "New, insert"
prot("New, insert" ,cLog)
endif
lUpdate := .f.
else // update
if lDebug
dcqdebugoff "Update"
prot("Update",cLog)
endif
lUpdate := .t.
endif
*------------------------------------------------------------
// aFields {{field name,field value,value}}
// example "field1","mydb->field",NIL
for y := 1 to len(aFields)
cVar := aFields[y,1] // var name
cValue := aFields[y,2] // value
if upper(cVar) == upper(cKeyField)
lIsKey := .t. // avoid adding key field to update statement
endif
aFields[y,14] := &(cValue)
if upper(cVar) == upper(cKeyField) .and. lUpdate
// do not update a key field
else
cVars += aFields[y,1] + ","
cValues += "?,"
cValue := aFields[y,2]
aadd(aData,aFields[y,3])
if lUpdate
cUpdate += aFields[y,1] + " = ?,"
endif
endif
next y
cVars := striplast(cVars,",") + ")"
cValues := striplast(cValues,",") + ")"
cUpdate := striplast(cUpdate,",")
if !lUpdate
cStmt := 'INSERT INTO ' + cTable + ' ' + cVars + ' VALUES ' + cValues + ";"
else
cStmt := 'UPDATE ' + cTable + ' SET ' + cUpdate + " WHERE " + cTable + "." + cKeyField + " = " + cWhere + ";"
endif
if lDebug
dcqdebugoff cStmt
prot("Statement:" + cStmt,cLog)
endif
*------------------------------------------------------------
oStmt := oConn:NewStatement()
oStmt:DisplayErrors := .t.
oConn:displayErrors := .t.
oConn:BeginTransaction()
oStmt:OnError := {||Break()}
BEGIN SEQUENCE
oStmt:SQLString := cStmt
oStmt:Prepare()
nResult := oStmt:Execute(aData )
if lDebug
dcqdebugoff "nResult:" + var2char(nResult)
prot("nResult:" + var2char(nResult),cLog)
endif
RECOVER
altd()
cError := "ERROR: " + if(lUpdate,"update","insert") + " failed, " + if(lUpdate,"transaction rollback","") +" errormsg.:" + oStmt:errormessage()
if lDebug
dcqdebugoff cError
prot(cError,cLog)
endif
if lUpdate
oConn:RollbackTransaction()
endif
SQLErrorLog(cError)
lOk := .f.
ENDSEQUENCE
oConn:EndTransaction()
oStmt:Destroy()
return lOk
Re: Refresh DCBrowse with SQL Express Demo
Good day Roger
Please have a look at _dcxbrow.prg on line 1286 will add a parameter to :RefreshAll where I sent the Object Changed to assign it back to :: DataSource and added a few new lines of 1316 to 1324.
This amendment addresses the issue when the oCursor Change Data
Attached is the _dcxbrow.prg
Please have a look at _dcxbrow.prg on line 1286 will add a parameter to :RefreshAll where I sent the Object Changed to assign it back to :: DataSource and added a few new lines of 1316 to 1324.
This amendment addresses the issue when the oCursor Change Data
Attached is the _dcxbrow.prg
Nolberto Paulino
Regards
Regards
Refresh ( ) DCBrowse with SQL Express Demo
digitsoft wrote:Good day Roger
Please have a look at _dcxbrow.prg on line 1286 will add a parameter to :RefreshAll where I sent the Object Changed to assign it back to :: DataSource and added a few new lines of 1316 to 1324.
This amendment addresses the issue when the oCursor Change Data
Attached is the _dcxbrow.prg
- Attachments
-
- _DCXBROW.ZIP
- (29.29 KiB) Downloaded 713 times
Nolberto Paulino
Regards
Regards
Re: Refresh DCBrowse with SQL Express Demo
Nolberto -
I looked at the code change you made in _DCXBROW.PRG.
Are you saying that these changes solve your problem?
If so, then I think I finally understand what you were trying to say.
Sorry, but I guess I understand Xbase++ code better than I understand translated Spanish.
I will add your changes to build 254.
I noticed that you added a parameter to DC_XbpBrowse:refreshAll(). I am going to apply this parameter to the other browse types such as BROWSE_ARRAY and BROWSE_DATABASE. Thank you for your contribution.
I looked at the code change you made in _DCXBROW.PRG.
Are you saying that these changes solve your problem?
If so, then I think I finally understand what you were trying to say.
Sorry, but I guess I understand Xbase++ code better than I understand translated Spanish.

I will add your changes to build 254.
I noticed that you added a parameter to DC_XbpBrowse:refreshAll(). I am going to apply this parameter to the other browse types such as BROWSE_ARRAY and BROWSE_DATABASE. Thank you for your contribution.
The eXpress train is coming - and it has more cars.
Re: Refresh DCBrowse with SQL Express Demo
Perfect Roger
If this change had the problem that was solved, when you have the 254 please let me to lower it.
If this change had the problem that was solved, when you have the 254 please let me to lower it.
rdonnay wrote:Nolberto -
I looked at the code change you made in _DCXBROW.PRG.
Are you saying that these changes solve your problem?
If so, then I think I finally understand what you were trying to say.
Sorry, but I guess I understand Xbase++ code better than I understand translated Spanish.
I will add your changes to build 254.
I noticed that you added a parameter to DC_XbpBrowse:refreshAll(). I am going to apply this parameter to the other browse types such as BROWSE_ARRAY and BROWSE_DATABASE. Thank you for your contribution.
Nolberto Paulino
Regards
Regards
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: Refresh DCBrowse with SQL Express Demo
I think you mean 264 not 254.