Unofficial Content
  • This documentation is valid for:

GeneXus version, GxPublicFactory allows opening a knowledge base with the newest GXPublic version that does not imply the conversion of the knowledge base structure.

E.g.:
If you have a Kb 80 and you have GXPublic Yi and 80 installed, you will attempt to open this KB with GXplublic 8.0; otherwise, you would have to convert it.
If you only have Gxpublic Yi version installed, on attempting to open the kb an error will occur: see Convert KB command underneath.
New method: ConnectionString
The ConnectionString() method provides the same parameters as the connect method plus an additional parameter with the connection string. This is useful to be able to use GxpublicFactory from .Net

The ConnectionString() method has three parameters, the first ones are the ones of the Connect method and the additional one is sConnectionString. The latter is a BSTR that has the connection string that Gxpublic must use to open this knowledge base. This is IDL "signature":

HRESULT ConnectionString(in BSTR sKBPath, inout int* pnVersion, out, retval BSTR* sConnectionString)

This is particularly useful to be able to use factory from .Net since the connect method returns an OleDBProvider that cannot interpret the Csharp code.

An example of the CSharp code would be the following:

int version = 0;
string path = @"C:ModelsExample";
OleDbConnection connection = new OleDbConnection();

try
{
   IConnectionFactory cf = new GXPUBLICFACTORYLib.ConnectionFactoryClass();
   string connectionString = cf.ConnectionString(path, ref version);
   connection.ConnectionString = connectionString;
   connection.Open();
}
   catch (COMException ex)
{
       throw new ApplicationException(String.Format("Error opening KB {0}
{1}", path, ex.Message]] ;
 }

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant