updating table from ODBC

Post Reply
xhbcoder
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

updating table from ODBC

Post by xhbcoder »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Jose,

Do you mean that you want to issue a SQL UPDATE command or that you want to update the DBF from the ODBC, or viceversa ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
xhbcoder
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Post by xhbcoder »

Antonio,

I am trying to update SQL table from Clipper/FiveODBC. Also want to execute stored procedure from Clipper/FiveODBC.

Thanks,

Jose
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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 ... " )
regards, saludos

Antonio Linares
www.fivetechsoft.com
xhbcoder
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Post by xhbcoder »

Antonio,

Thanks, I was able to update the first record but I am getting an error with the skip method.

Regard,

jose
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Jose,

> I am getting an error with the skip method.

What error do you get ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
xhbcoder
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Post by xhbcoder »

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
Last edited by xhbcoder on Thu Dec 21, 2006 7:02 pm, edited 1 time in total.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Have you located on what source code line the GPF ocurrs ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
xhbcoder
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Post by xhbcoder »

antonio,

Thanks for the quick reply.

The GPF occurs at oRdd:Skip(1) && <-- GPF error here

and and cAliasname line 0 when I close the Browse.

Any idea?

regards,

jose
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Jose,

You should place some traces (MsgInfo() calls) at METHOD Skip( nRecs ) CLASS TDbOdbc to see where it is failing (source\classes\tdbodbc.prg)
regards, saludos

Antonio Linares
www.fivetechsoft.com
xhbcoder
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Post by xhbcoder »

Antonio,

I wonder why it may fail inside Fivewin class. Kindly check if I have the correct environment.

Clipper5.2e
Comix
FW24
Windows Xp Professional service pack2
MS SQL server 2005

I use xbase skip command to move records and looks working fine so far.

Regards,
Jose
xhbcoder
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Post by xhbcoder »

Antonio,

Furthermore, even the Fivewin Browse New Button generates a [#8101] class:23000 error message followed by a GPF. The same with xbase append blank command.

Thanks,

Jose
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
xhbcoder
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Post by xhbcoder »

Antonio,

Thanks for the reply. Currently I have FW 2.4 for xhharbour but if it is not enough I will upgrade to the latest.

thanks again.

Jose
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Jose,

FWH 2.4 is an old version, you should upgrade to FWH 6.12 (current one).
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply