Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor

Another of the latest videos from the SAP Database and Tools Academy (

The video is pretty much self explanatory.  Just reiterate the main points here and provide some of the sample code.

1.  Create a .Net assembly target and select CustomVisual as the object type to be created.

2.  Create your visual user object in the WPF panel that is presented.

3.  Go to the Objects tab on the project and make sure you select the visual component you want to deploy.

4.  In addition to the assembly containing your visual component, PowerBuilder will place the following runtime assemblies in the output folder.  Give all of them to the Visual Studio developer.

5.  The visual studio developer will create a reference in their Toolbar to the new WPF control by selecting Choose Items... and then using the Browse option under WPF control to navigate to your assembly and then select the visual control within it.

6.  The Visual Studio developer can now drop the PowerBuilder visual object onto a WPF window in their application.  There may be a couple of errors the first time they attempt to compile the application:

a.  If the WPF application has been created with a Target Framework Reference of ".Net Framework 4 Client Profile" they will need to change it to ".Net Framework 4".  The assembly that PowerBuilder created indicates it has a dependency on System.Web, which is not included in the Client Profile version of the target framework.

b.  When the Visual Studio developer added your component to their WPF window, Visual Studio automatically added a reference to it to the project.  The Visual Studio developer will also need to add an explicit reference to Sybase.PowerBuilder.WPF.Controls to the project.

If you are incorporating a DataWindow control in your custom visual user object, you will need to make a few additional changes.

1.  Assuming that you are going to be using ADO.Net to connect to the database, you will need to provide these additonal runtime assemblies to the Visual Studio developer.  Note that PowerBuilder will not automatically copy them to the output folder for you.


Also note that the following runtime assemblies will also need to be given to the Visual Studio developer, because the DataWIndow uses them to read SRD files:


2.  The Visual Studio developer will need to add explicit references to the antlr3.runtime.dll and Sybase.PowerBuilder.DataSource.Sharing.dll assemblies.

3.  If you want to have the Visual Studio developer pass in an established connection to the database and have the DataWindow within the PowerBuilder component use it instead of establishing it's own seperate connection to the database, you'll need to add a method to the custom visual user object that takes an argument of System.Object and then uses the SetAdoConnection method on the transaction object to assign that argument as a proxy connection.  For example:

boolean  lb_rc
integer  li_rc
  SQLCA.DBParm = "Namespace='Oracle.DataAccess.Client'"
  lb_rc = sqlca.SetAdoConnection(a_conn)
  if not lb_rc then
    MessageBox ( "Error", "SetAdoConnection failed" )
    return -1
    connect using sqlca ;
    if sqlca.SQLCode <> 0 then
      MessageBox ( "Error", "Connect failed: " + sqlca.SQLErrText )
      return -1
      li_rc = dw_1.SetTransObject ( sqlca )
      if li_rc < 0 then
        MessageBox ( "Error", "SetTransObject failed" )
        return -1
        return 1
      end if
    end if
  end if
catch ( Throwable e )
  Exception exp
  exp = create Exception
  throw exp
end try

4.  The Visual Studio developer then creates a proxy object based on the IAdoConnectionProxy interface, create it based on AdoConnectionProxy, assigns the connection and transaction to it, and passes into your method on the custom visual user object.

short rc;
String connectString = "Data Source=//oracle:1521/orcl;User Id=scott;Password=tiger2";
Oracle.DataAccess.Client.OracleConnection conn = new Oracle.DataAccess.Client.OracleConnection(connectString);
Oracle.DataAccess.Client.OracleTransaction trans = conn.BeginTransaction();
Sybase.PowerBuilder.DataSource.Sharing.IAdoConnectionProxy proxy;
proxy = new Sybase.PowerBuilder.DataSource.Sharing.AdoConnectionProxy();
proxy.Connection = conn;
proxy.Transaction = trans;
rc = u_customvisual1.AssignConnection(proxy);

5.  Note that when you have methods you want to expose on the custom visual user object, you select those rather than the custom visual user object in the project painter, so that PowerBuilder knows it needs to expose those methods on the control in the assembly.

Labels in this area