updating table from ODBC
updating table from ODBC
Hi all,
I am trying to update table from clipper through FiveODBC. I can't find sample codes to initiate the update from the documentation.
Thanks,
Jose
I am trying to update table from clipper through FiveODBC. I can't find sample codes to initiate the update from the documentation.
Thanks,
Jose
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Jose,
To update a field simply assign it as you do in Clipper:
fieldName1 := newValue1
fieldName2 := newValue2
...
oRdd:oOdbc:Update( .T. )
Please review Class TRddODbc and Class TODBC Methods PutValue() to see how it works.
You can also issue a generic SQL UPDATE command using oRdd:oOdbc:Execute( "UPDATE ... " )
To update a field simply assign it as you do in Clipper:
fieldName1 := newValue1
fieldName2 := newValue2
...
oRdd:oOdbc:Update( .T. )
Please review Class TRddODbc and Class TODBC Methods PutValue() to see how it works.
You can also issue a generic SQL UPDATE command using oRdd:oOdbc:Execute( "UPDATE ... " )
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
I am getting a GPF error. Thanks
********************
function ODBC_update && testing update
********************
local oRdd,afiles,n:=0,cTable,oDbf
oRdd := TRddOdbc():New("rtl_polling", "SA", "*****")
*oRdd := TRddOdbc():New("Northwind", "SA", "*****")
If !oRdd:oOdbc:lSuccess
oRdd:oOdbc:ShowErrorList("ODBC session not successfully initialized, aborting...")
oRdd:End()
return nil
Endif
// oRdd:oOdbc:lAbort := .f.
aFiles := oRdd:oOdbc:GetTables("*", .F. ) && returns all tables
if len(aFiles) == 0
MsgAlert("There are not tables on that database, aborting...",;
"ODBC Table selection")
oRdd:End()
return nil
endif
cTable := "test_jd"
oRdd:oOdbc:lCsrDyn := .t.
alert("here")
USE (cTable) VIA "ODBC" NEW ALIAS "_"+cTable+"_"
oDbf:=oRdd:getTable(cTable)
field->Field3="testxx"
oRdd:Skip(1)
field->Field3="test3"
*field->Field3="test update2"
*do while n <= 10
* n++
* oRdd:oOdbc:append()
* field->field2=n
*enddo
browse()
oRdd:End()
return nil
********************
function ODBC_update && testing update
********************
local oRdd,afiles,n:=0,cTable,oDbf
oRdd := TRddOdbc():New("rtl_polling", "SA", "*****")
*oRdd := TRddOdbc():New("Northwind", "SA", "*****")
If !oRdd:oOdbc:lSuccess
oRdd:oOdbc:ShowErrorList("ODBC session not successfully initialized, aborting...")
oRdd:End()
return nil
Endif
// oRdd:oOdbc:lAbort := .f.
aFiles := oRdd:oOdbc:GetTables("*", .F. ) && returns all tables
if len(aFiles) == 0
MsgAlert("There are not tables on that database, aborting...",;
"ODBC Table selection")
oRdd:End()
return nil
endif
cTable := "test_jd"
oRdd:oOdbc:lCsrDyn := .t.
alert("here")
USE (cTable) VIA "ODBC" NEW ALIAS "_"+cTable+"_"
oDbf:=oRdd:getTable(cTable)
field->Field3="testxx"
oRdd:Skip(1)
field->Field3="test3"
*field->Field3="test update2"
*do while n <= 10
* n++
* oRdd:oOdbc:append()
* field->field2=n
*enddo
browse()
oRdd:End()
return nil
Last edited by xhbcoder on Thu Dec 21, 2006 7:02 pm, edited 1 time in total.
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Jose,
Your FW is a quite an old version, though your environment looks ok.
As we have publically commented several times, we have focused on FWH and ODBC 32 bits support instad of FiveODBC RDD 16 bits, thats why we have not done further development on it. Most of our users are using FWH 32 bits.
Using Harbour and xHarbour we don't need to hack Clipper, as now full source code is available for development. We strongly recommend you to port your application to FWH 32 bits.
Your FW is a quite an old version, though your environment looks ok.
As we have publically commented several times, we have focused on FWH and ODBC 32 bits support instad of FiveODBC RDD 16 bits, thats why we have not done further development on it. Most of our users are using FWH 32 bits.
Using Harbour and xHarbour we don't need to hack Clipper, as now full source code is available for development. We strongly recommend you to port your application to FWH 32 bits.
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact: