FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Request : new PostgreSQL OLEDb-Provider
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Request : new PostgreSQL OLEDb-Provider
Posted: Mon Sep 11, 2023 04:17 AM
hi,

i have search for FREE OLEDB-Provider for PostgreSQL and found at Sourceforge.net
PM PostgreSQL OLEDB Files
https://sourceforge.net/projects/pmpostgresqlole/files/
it include 32 / 64 Bit Version and Source

---

i have regsvr32 PMDAPGS.dll and got this when call OdbcConnect()


i can "connect" to PostgreSQL Server


but there are "no Table" shown ... :(



---

i have "check" FW_RDBMSName() but it seems "empty" ... hm
Code (fw): Select all Collapse
      c += IfNil( oCn:Properties( "DBMS Name" ) :Value, "" ) + " " + ;
                  IfNil( oCn:Properties( "Extended Properties" ) :Value, "" )
      CATCH
fwlog c
i "guess" Fivewin dows not "know" this Driver (String)
Code (fw): Select all Collapse
"Provider=PMDAPGS;Server=<server_name>;Database=<db_name>;User=<user>;Password=<password>;Port=<port>"
---

i have put DLL into
c:\Program Files\Common Files\System\Ole DB\PMDAPGS.dll
as Readme say
NOT under
c:\Program Files\Common Files\System\ado\

i have not Idea what is going wrong ... need some help please
greeting,

Jimmy
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Request : new PostgreSQL OLEDb-Provider
Posted: Mon Sep 11, 2023 06:19 AM
I am not even able to register the dll.
Got this error.

Unable to proceed
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Request : new PostgreSQL OLEDb-Provider
Posted: Mon Sep 11, 2023 06:22 AM
i have "check" FW_RDBMSName() but it seems "empty" ... hm
Do not worry at all about this function.
This is basically intended for internal usage to help the function FW_ValToSQL()
It has no effect on Opening ADO connctions, Opening RecordSets and using the recordsets in any manner we need.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Request : new PostgreSQL OLEDb-Provider
Posted: Mon Sep 11, 2023 08:11 AM
hi,
nageswaragunupudi wrote:I am not even able to register the dll.
Got this error.
Unable to proceed
have you "RegSvr32" 32 / 64 Bit DLL "as Administrator" :?:

on 64 Bit OS i have use 64 Bit DLL "only" and copy it to
c:\Program Files\Common Files\System\Ole DB\PMDAPGS.dll
greeting,

Jimmy
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Request : new PostgreSQL OLEDb-Provider
Posted: Mon Sep 11, 2023 08:24 AM
nageswaragunupudi wrote:It has no effect on Opening ADO connctions, Opening RecordSets and using the recordsets in any manner we need.
hi,

ok ... but why "is"
Code (fw): Select all Collapse
   oCn:Properties( "DBMS Name" ):Value
and/or
Code (fw): Select all Collapse
   oCn:Properties( "Extended Properties" ):Value
Empty() ... :?:

it is "listed" when call
Code (fw): Select all Collapse
   oDL := CreateObject( "Datalinks" ) :PromptNew()
greeting,

Jimmy
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Request : new PostgreSQL OLEDb-Provider
Posted: Mon Sep 11, 2023 09:53 AM
If you want to see all properties of any connection object:
Code (fw): Select all Collapse
oCn := FW_OpenAdoConnection( <your-connectionstring>, .t. )
if oCn == nil
   ? "Fail"
else
   XBOWSER oCn  // this shows all properties
   // other works
   oCn:Close()
endif
Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Request : new PostgreSQL OLEDb-Provider
Posted: Tue Sep 12, 2023 01:41 PM
hi

thx for Answer.
nageswaragunupudi wrote:
Code (fw): Select all Collapse
oCn := FW_OpenAdoConnection( <your-connectionstring>, .t. )
if oCn == nil
   ? "Fail"
else
   XBOWSER oCn  // this shows all properties
   // other works
   oCn:Close()
endif
there is a Typo in CODE
XBOWSER must be XBROWSER

---

i have use it and got this

i have put all Variable into String which was wrong :roll:

this is right
Code (fw): Select all Collapse
   EDITVARS cServer, cDatabase, cUserName, cPassword TITLE "PMDAPGS" + " : Server login"
   oCn:Open( "Provider='PMDAPGS';Server='"+cServer+"';Database='"+cDataBase+"';User='"+cUsername+"';Password='"+cPassword+"'")
now i got to Table and can XBROWSER it :D

than i try "edit" ... but it does not work :shock:
need any Tip what i´m doing wrong :idea:
greeting,

Jimmy
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Request : new PostgreSQL OLEDb-Provider
Posted: Tue Sep 12, 2023 02:47 PM

Can I see your code for opening ado connection and recordset?

Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Request : new PostgreSQL OLEDb-Provider
Posted: Tue Sep 12, 2023 07:41 PM
here is the CODE
Code (fw): Select all Collapse
PROCEDURE USE_Postgre()
LOCAL oCn     := TOleAuto() :New( "ADODB.Connection" )
LOCAL oCat    := TOleAuto() :New( "ADOX.Catalog" )
LOCAL oRs     := TOleAuto() :New( "ADODB.Recordset" )
LOCAL aTables := {}, cTable
LOCAL oError, lFalse := .F.

LOCAL cServer   := "192.168.2.118"
LOCAL cDataBase := "mdidemo"
LOCAL cUsername := "postgres"
LOCAL cPassword := "********"
LOCAL cPort := "5432"

   EDITVARS cServer, cDatabase, cUserName, cPassword TITLE "PMDAPGS" + " : Server login"

   try
      oCn:Open( "Provider='PMDAPGS';Server='"+cServer+"';Database='"+cDataBase+"';User='"+cUsername+"';Password='"+cPassword+"'") // ;Port="+cPort )

   CATCH oError
      MsgInfo( oError:Description, "open Error PostgreSQL" )
      lFalse := .T.
   END TRY

   IF EMPTY( oCn ) .OR. EMPTY( oCat ) .OR. lFalse
      RETURN
   ENDIF

   oCat:ActiveConnection := oCn
   oRs := oCn:OpenSchema( 20 )                                        // adSchemaTables

   WHILE !oRs:Eof()
      AADD( aTables, oRs:Fields:Item( "Table_Name" ) :Value )
      oRs:MoveNext()
   END

   XBROWSER aTables SELECT cTable := aTables[ oBrw:nArrayAt ]
   oRs:Close()

   oRs:CursorType := 1                                                // opendkeyset
   oRs:CursorLocation := 3                                            // local cache
   oRs:LockType := 3                                                  // lockoportunistic

   IF !EMPTY( cTable )
      try
         oRs:Open( "SELECT * FROM " + cTable, oCn )                   // Password="abc" )
      catch oError
         MsgInfo( oError:Description )
      END TRY

      XBROWSER( oRS ) FASTEDIT AUTOFIT
   ENDIF

RETURN
it work under Windows 10 32 Bit AND 64 Bit in Version 10.0.19045.3448 :)
but it crash under Windows 11 Version 10.0.22621.2283 without any *.LOG :shock:

FWH 23.07 32 Bit BCC
FWH 23.04 64 Bit MSVC
greeting,

Jimmy
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Request : new PostgreSQL OLEDb-Provider
Posted: Mon Sep 18, 2023 04:33 PM
hi,

as i have no "real" OLEDB Driver for PostgreSQL i try to use PMDAPGS.DLL
i can XBOWSER / XBROWSE PostgreSQL Table but "save" seems not work

have found out that PMDAPGS.dll was "identify" as "XBR" when try to "save" PostgreSQL Data
but i need
Code (fw): Select all Collapse
METHOD SAVE( lCheckValid, lSilent ) CLASS TDataRow
   ...
   ELSEIF ::cSrcType == "PQQ"
what do i miss ... :?:
greeting,

Jimmy
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Request : new PostgreSQL OLEDb-Provider
Posted: Tue Sep 19, 2023 02:42 AM
but "save" seems not work
Try inline edit.

Any valid ADO recordset is recognized as RecordSet.

To start with just use
Code (fw): Select all Collapse
XBROWSER oRs FASTEDIT
Try to add CursorLocation of connection object also as adUseClient.'
Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Request : new PostgreSQL OLEDb-Provider
Posted: Wed Sep 20, 2023 11:01 AM
hi,

thx for Answer.

i do have already CursorLocation and FASTEDIT in Sample ...

what do you mean with "inline edit" , how :?:
greeting,

Jimmy

Continue the discussion