1. Chris Lerwill
  2. PowerServer
  3. Thursday, 30 March 2023 15:53 PM UTC

I am in the process of attempting to convert a client-server application to be delivered by PowerServer.  After I publish the AppModels and run the application I am finding the most common issue is in a c# model generated for a datawindow that has columns having a "Number" datatype.  The generated model usually gets a "double?" datatype but when I view the column it is being mapped for, that column is defined as an INT in SQL Server. 

Below is an example of how the column is defined in the source editor of a datawindow...

 column=(type=number updatewhereclause=no name=rth_id dbname="rth_id" )

 

My application has many datawindows and this has been found to be an issue in hundreds of them.  When I do a search in the IDE there are 3000+ instances.

To date, I manage this issue by using a text editor to do a mass search-and-replace on the c# models.  Is there a setting I am missing in SnapDevelop that will allow me to tell the model generation process to use Int32 for any datawindow columns having a "number" datatype?

Accepted Answer
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Friday, 31 March 2023 04:23 AM UTC
  2. PowerServer
  3. # Permalink

Hi Chris, Please open a support ticket. https://www.appeon.com/standardsupport/newbug


I think it is possible these are bugs because you shouldn't have to make extensive change to your app to deploy it with PowerServer 2022.

Comment
  1. Chris Lerwill
  2. Monday, 3 April 2023 13:13 PM UTC
Thanks for the input, Armeen. I opened a support ticket for the issue "the c# model for a DataWindow whose SQL is a stored procedure wanting 14 arguments was not generated correctly" and David Xiong reported they were able to reproduce and suggested a workaround.



As for the original issue that caused me to make my initial post, I think I am going to open a support ticket for that one...I just haven't figured out how much information I need to supply. I know what it is like to have customers tell you something is wrong but offer insufficient information.
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Thursday, 6 April 2023 19:58 PM UTC
Thanks for your efforts to equip us so we can properly do our job. Our team confirms it is a bug and will be fixed in version 2022 R2.
  1. Helpful
There are no comments made yet.
Chris Lerwill Accepted Answer Pending Moderation
  1. Thursday, 6 April 2023 19:45 PM UTC
  2. PowerServer
  3. # 1

Posting an update on this...both issues I mention in this thread have been reviewed by Appeon Support and they tell me the functionality will likely be fixed in PowerServer 2022 R2 BETA.

 

The main issue that led me to post this question is a bug and I will need to wait until PowerServer 2022 R2 BETA to see improvements.  The detailed reason for the behavior is...

This issue is because there is a parameter in the stored procedure; In the DataWIndow the parameter is a fixed value. 
PowerServer parsed this parameter name incorrectly, failing in executing the stored procedure and thus was unable to get the resultset.
As a result, the C# model was generated by mapping the data types in the DataWindow, which led to the error.

 

 

For the issue I mentioned regarding the c# model missing a parameter...it appears the way the datawindow was parsed during the generation process produced the issue.  There are both a "chassis" and "chassis2" datawindow argument defined but "chassis2" wasn't being passed to the appropriate stored procedure parameter, instead "chassis" was being passed to 2 different stored procedure parameters when executing the stored procedure.  Appeon's detailed reason is...

The cause of this problem is due to the @chassis2 = :chassis in the Stored Procedure Data Source of DataWindow

 

Thank you to everyone who responded tp this question...I really appreciate the help!

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 6 April 2023 20:35 PM UTC
Thanks for the update Chris!
  1. Helpful
There are no comments made yet.
David Xiong @Appeon Accepted Answer Pending Moderation
  1. Friday, 31 March 2023 09:40 AM UTC
  2. PowerServer
  3. # 2

Hi Chris,

 

When PowerServer converts DataWindows to C# Models, it follows the principles below:

  1. When the data source of the DataWIndow is a stored procedure when converting to C# Model, it determines the column types by checking the result after running the stored procedure with default parameters. If it fails to run the stored procedure, it will be then converted according to the column types in DataWindow. For example, "Number" will be converted to C# "Double" in the model.
  2. When the data source of the DataWindow is Select SQL when converting to C# Model, the data types of the columns will be obtained from the database table. If it fails to query the database, it will not generate the corresponding C# Model in AppModels. An error will be shown on the error tab of the PowerServer Deployment window.

 

So for the issue where a number in DataWindow is translated into double in C# model, we recommend that you check the following:

  1. Confirm whether the database is connected correctly and whether the DB user has sufficient permission to access related stored procedures and tables when PowerServer generates models during deployment.
  2. Check the relevant stored procedures, and see whether the resultset structures are different depending on the input. If the same stored procedure returns resultsets with different columns or different column data types, it will cause a mismatch error. PowerServer doesn't support this case.

 

About the mapping of the SQLServer database data type in C# Model, you can refer to the link below

https://docs.appeon.com/ps2022/SQL_server_data_type_mappings.html

 

For the issue "the c# model for a DataWindow whose SQL is a stored procedure wanting 14 arguments was not generated correctly", we suggest that you submit another ticket separately and provide a small test case that can reproduce the issue (including procedure syntax, table syntax, test data) for us to reproduce and analyze the issue. Thank you!

 

Regards,

David

Comment
  1. Chris Lerwill
  2. Monday, 3 April 2023 13:16 PM UTC
Thanks, David. I checked #1 and that didn't help. As for #2...I suspect it may be an issue with some of the models, but not all of them. I think I will open a support ticket as Armeen suggests shortly but I want to try to find a good case to provide first.
  1. Helpful
There are no comments made yet.
Chris Lerwill Accepted Answer Pending Moderation
  1. Thursday, 30 March 2023 20:51 PM UTC
  2. PowerServer
  3. # 3

Good suggestion Francisco.  I'm probably going to spend more time turning my application into a "cloud" app before I request any changes, though...because I'm not sure such a change would be beneficial.  In my current project I am seeing times when I would want to see c# model datatypes be Int32? and others when a double? is perfectly appropriate. 

 

It does appear the "Build & Deploy PowerServer Project" process needs refining.  I just debugged another issue that arose from that process and found that the c# model for a DataWindow whose SQL is a stored procedure wanting 16 arguments was not generated correctly...the "DwProcedure" definition in the model was missing a parameter even though it was defined below.  I've attached an image in case I didn't describe it clearly.

 

Anyway, I will press on because nothing I've found has been a show-stopper.

 

Attachments (1)
Comment
There are no comments made yet.
Chris Lerwill Accepted Answer Pending Moderation
  1. Thursday, 30 March 2023 17:19 PM UTC
  2. PowerServer
  3. # 4

Thanks for the explanations. 

 

It is not realistic for me to modify the many stored procedures as there are other non-PowerBuilder applications that may use them.  I did attempt to replace every instance of "double" with "Int32" and that improved some areas but broke others...like where the "Number" DataWindow datatype is for a column in the database that is a "Float"...so, I guess even if SnapDevelop had the setting I wondered about, it would create problems in a different way if I used it.

 

Sounds like the primary solution for me is to keep notes on which DB columns are found to be mapped incorrectly and fix those specific issues in their respective c# models.

Comment
  1. Francisco Martinez @Appeon
  2. Thursday, 30 March 2023 17:55 PM UTC
Maybe you could submit an enhancement request for this? Allowing to specify the column/argument type with more granularity for numeric types? Sounds like something that could come in useful for a lot of projects.



Regards - Francisco
  1. Helpful 1
There are no comments made yet.
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Thursday, 30 March 2023 16:46 PM UTC
  2. PowerServer
  3. # 5

Hi Chris,

The DataWindows use stored procedures as DataSource? Or plain tables?

 

Regards,
Francisco

 

Comment
  1. Chris Lerwill
  2. Thursday, 30 March 2023 16:55 PM UTC
Most use stored procedures...but, some do not.



It appears that DataWindow argument datatypes that are "Number" are also turned into "double?" in the generated c# models.



Thanks for the quick reply.
  1. Helpful
  1. Francisco Martinez @Appeon
  2. Thursday, 30 March 2023 17:03 PM UTC
When PowerServer generates the C# models, if the datawindow is backed by a Stored Procedure, it determines the column types by running the stored procedure with the default parameters. If this fails, then looks at the DW column definition, for which the "Number" datatype gets mapped to C#'s "double". One way to solve this is by modifying the SP so as to have it return a dataset (if empty) that allows PowerServer to see the column types when generating the C# models



Regards - Francisco
  1. Helpful
  1. Francisco Martinez @Appeon
  2. Thursday, 30 March 2023 17:05 PM UTC
As for the arguments, unfortunately in PB there's not a lot of granularity on numeric types (on datawindows). Everything is categorized under "number". For this reason, PS takes the safe route and maps "number"s to doubles
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.