xsharp.eu • Object compatibility between VO and VS
Page 1 of 1

Object compatibility between VO and VS

Posted: Fri Jan 20, 2023 2:04 pm
by gjbiagiotti
I’m developing a class in Visual Studio to handle SQL with PostgreSQL and NpgSql. This class I going use in VO.
The problem is in the method Select that it return a DataSet object. This object is not compatibily with VO.
Is there a method in VO that allows both data to be compatible?
Public oTabla As Npgsql.NpgsqlDataReader

Public Function PG_Select(ByVal cCadena As String) As Boolean

' Devuelve: TRUE error - FALSE sin error

Dim comando As New Npgsql.NpgsqlCommand

Try
comando.Connection = oConexion
comando.CommandType = CommandType.Text
comando.CommandText = cCadena

oTabla = comando.ExecuteReader

Return False

Catch ex As Exception
Return True 'error
End Try

End Function

Thank you
Gerard

Object compatibility between VO and VS

Posted: Fri Jan 20, 2023 2:18 pm
by wriedmann
Hi Gerard,
to accomplish that you need to write your own class and expose that to COM.
You can find a sample here:
https://www.riedmann.it/download/PostgreSQLReader.zip
It is a complete PostgreSQL interface for VO, written in X# and made available to VO through COM (works with SxS, so no registration needed).
I'm using that library myself, and have similar libraries also for SQLite and MySQL.
Wolfgang

Object compatibility between VO and VS

Posted: Fri Jan 20, 2023 2:39 pm
by gjbiagiotti
Thanks Wolfgang but I already have a library similar to the one you sent.
What I am designing is a class library that replaces the VO SQL libraries.
Thank you.
Gerard

Object compatibility between VO and VS

Posted: Fri Jan 20, 2023 2:48 pm
by wriedmann
Hi Gerard,
you should look at the PGDataTable and the PGDataRecord classes in my sample to see how to can expose arbitrary objects to COM.
If you would like to expose a class similar to the DataSet object you have to write a child class or a proxy class that exposes the needed methods and properties to COM.
Of course you will need also COM exposed proxy classes for all objects that are returned by your dataset object.
Wolfgang