FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ADO Problem
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
ADO Problem
Posted: Tue Jul 01, 2014 10:07 AM

HI,

This code sometimes work ok, sometimes produce error:
Error description: Error ADODB.RecordSet/6 DISP_E_UNKNOWNNAME: MOVEFIRST

try
   oRs := TOleAuto():New( 'ADODB.RecordSet' )
   WITH OBJECT oRs
      :ActiveConnection := oCn
      :Source           := 'SELECT * from mytable'
      :CursorLocation   := 3  
      :Open()
   END
catch oErr
   FW_ShowAdoError(oCn)
   return .f.
end try

oRs:MoveFirst()
.
.
.

oRs:Close()
oCn:Close()

After few days i have seen that it is huppaning when table is empty

Is that mean that we must always control oRs:RecordCount ????
Is that standard ADO behavior or therw is some other solution ?

Second case
IF :Source is not SELECT statement for example
:Source := 'SET PDQPRIORITY 95'
than oRs:State = 0 and all Methods produce error ...
Error description: Error ADODB.RecordSet/6 DISP_E_UNKNOWNNAME: CLOSE
Question: IS sql statement executed ?
IS that mean thet in this cases it is not need of closing recordset ?
Must control oRs:State in any cases ?

In this case CATCH oErr dont report error ...

ONE MORE Qusetion.
If SQL statement is executed ... is server returning message what is maded ?
Something like "100 Records inserted"
If yes how can i get that message ?
IS there some function like FW_ShowAdoResult(oCn) ?

Best Regards,

Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: ADO Problem
Posted: Tue Jul 01, 2014 11:19 AM
Avista,

It's normal that you get an error if you do a oRs:MoveFirst() on a empty recordset.

That's why I use
Code (fw): Select all Collapse
IF !oRs:eof()
   oRs:MoveFirst()
   ...

ENDIF


I don't know what you mean for the second case.
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ADO Problem
Posted: Tue Jul 01, 2014 10:56 PM

cSql := "UPDATE ......" or "INSERT INTO ..."

oCn:Execute( cSql, @nRows, adCmdText )
? nRows

Regards



G. N. Rao.

Hyderabad, India
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
Re: ADO Problem
Posted: Thu Jul 03, 2014 12:42 PM

Marc, Rao

Thanks for reply

Regards,

Continue the discussion