Diferencia entre oRs:save y oRs:update

Diferencia entre oRs:save y oRs:update

Postby artu01 » Thu Sep 03, 2020 5:55 pm

Gente utilizo ADO para trabajar con tablas de sql server
Mi duda es algunas veces me funciona el oRs:save pero a veces bota error y no se el motivo, pero si utilizo oRs:Update siempre funciona

Cuando debo de utilizar cada una de ellas?

Estoy con la version fwh 17.12
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
artu01
 
Posts: 400
Joined: Fri May 11, 2007 8:20 pm
Location: Lima

Re: Diferencia entre oRs:save y oRs:update

Postby nageswaragunupudi » Fri Sep 04, 2020 3:02 am

ADO RecordSet methods are independent of FWH version and they behave the same across all versions of FWH.

Use oRs:Update() method ( not Save() method ) to save any changes in the data.
There are two ways of using.

1)
Code: Select all  Expand view

oRs:Fields( "city" ):Value := "London"
oRs:Fields( "Age"  ):Value := 34
oRs:Update()  // writes the above changes to the server.
 


2)
Code: Select all  Expand view

oRs:Update( { "city", "age" }, { "London", 34 } )
// This changes and values and also writes the changes to the server.
 


Method oRs:Save()
This method is used to save contents of RecordSets to Disk in either XML format of ADTG (micorosoft proprietory) format

Code: Select all  Expand view

oRs:Save( "c:\folder\filename.adtg", 0 )
oRs:Save( "c:\folder\filename.xml",  1 )
 


Here you find all datas and methods of ADO RecordSet object:
https://www.w3schools.com/asp/ado_ref_recordset.asp

Better we completely go though this tutorial, before working with ADO
https://www.w3schools.com/asp/ado_intro.asp
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Diferencia entre oRs:save y oRs:update

Postby artu01 » Sun Sep 06, 2020 3:17 am

Thank you Master
i had seen posts in this forum using the method save of this way
Code: Select all  Expand view

 oRS:Fields( 'Descri' ):value:=cDescri
 oRs:Save()
 


i myself have checked that it works but not always (that was the reason for my question)

Using the method update() never fail

Code: Select all  Expand view

oRS:Fields( 'Descri' ):value:=cDescri
oRS:Update()
 
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
artu01
 
Posts: 400
Joined: Fri May 11, 2007 8:20 pm
Location: Lima

Re: Diferencia entre oRs:save y oRs:update

Postby nageswaragunupudi » Sun Sep 06, 2020 3:45 am

artu01 wrote:Thank you Master
i had seen posts in this forum using the method save of this way
Code: Select all  Expand view

 oRS:Fields( 'Descri' ):value:=cDescri
 oRs:Save()
 


i myself have checked that it works but not always (that was the reason for my question)

Using the method update() never fail

Code: Select all  Expand view

oRS:Fields( 'Descri' ):value:=cDescri
oRS:Update()
 


oRs:Save() never writes data to the server.
When record pointer is moved, oRs:Update() is automatically executed without your knowledge.

Note:
FWH MariaDB library uses both Save() and Update() for writing changes to the server. That is not ADO.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Diferencia entre oRs:save y oRs:update

Postby artu01 » Sun Sep 06, 2020 11:20 pm

It's understood Mr. Rao
Thank you
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
artu01
 
Posts: 400
Joined: Fri May 11, 2007 8:20 pm
Location: Lima


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], russimicro and 61 guests