1. Saul Erhmy
  2. SnapDevelop
  3. Tuesday, 4 October 2022 18:27 PM UTC

Hi, 

I was able to convert PB datawindows to C# and currently I am trying to convert my whole PB app to C#. In PB I used an operation .GetItemNumber(), but what would this operation be in C# for the DataStore? There are three that I see that might be the solution: getItem(), getItems(), getItemStatus(). Maybe it's not any of them though. If someone knows what the equivalent of GetItemNumber from PB is in C# I would greatly appreciate it.

Thanks!

Accepted Answer
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 4 October 2022 18:53 PM UTC
  2. SnapDevelop
  3. # Permalink

Hi Saul,

Conceptually, to accomplish the same thing the GetItemNumber function does, you:
1) Retrieve the object corresponding to the Row you want to read
2) Access the object's property (the number you're looking for)

Suppose you want to access the Department ID number of a given Department DataStore. One way you could do that is like this:

 

Hope this helps.

Regards,
Francisco

Comment
  1. Saul Erhmy
  2. Tuesday, 4 October 2022 19:45 PM UTC
Hi Francisco, I have one more follow up question if you don't mind. What would be the equivalent of SomeDataWindow.Object.Data = PB_Structure in C#?
  1. Helpful
  1. Francisco Martinez @Appeon
  2. Tuesday, 4 October 2022 20:18 PM UTC
Hi Saul. Sorry, I'm not very well-versed in PowerBuilder. What does that statement do?
  1. Helpful
  1. Saul Erhmy
  2. Tuesday, 4 October 2022 20:50 PM UTC
I'm not very well-versed in PowerBuilder either haha. I believe it sets the dataWindows data to whatever the array's data is? Here is a link if I didn't describe what it does correctly, https://docs.appeon.com/pb2021/datawindow_reference/XREF_88199_Techniques_for.html.
  1. Helpful
There are no comments made yet.
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 4 October 2022 21:00 PM UTC
  2. SnapDevelop
  3. # 1

Hi Saul,

If what you want to do is effectively replace the contents of the .NET DataStore, this is what I would do:

1) Clear the contents of the .NET DataStore
2) Insert the new contents into the .NET DataStore

In code it would look something like this:

I hope this is what you're hoping to achieve.

Regards,
Francisco

Comment
  1. Saul Erhmy
  2. Monday, 10 October 2022 16:09 PM UTC
Oh Wait, I just no looked at your first post on this thread and you initialized the non generic datastrore by doing var nonGenericDataStore = new DataStore(d_department, dataContext). Which i think is exactly what I am doing when i tried new DataStore("myDWattribute", MyOracleconnection). But im not sure why I get thrown the "No MetaData for DataWindow 'myDWAttribute' found" error.
  1. Helpful
  1. Francisco Martinez @Appeon
  2. Tuesday, 11 October 2022 13:29 PM UTC
Hi Saul,

Make sure a class decorated with the attribute [DataWindow("myDWattribute", someotherparameter)] exists in your solution.

The line "new DataStore("myDWattribute", MyOracleconnection)" tries to look for such a class in your project. This annotation is generated when you import your DataWindow through the DataWindow converter.

Regards, Francisco
  1. Helpful
  1. Saul Erhmy
  2. Tuesday, 11 October 2022 20:16 PM UTC
What you say makes sense but I'm still confused because I'm getting thrown errors. Inside of my datawindow class, it is defined as [DataWindow("myDWattribute", DWStyle.Default)]. I can't change the 2nd parameter to anything else it has to be a DWNet.Data.DwStyle.



And the line "new DataStore("myDWattribute", MyOracleconnection)" that second parameter needs to be a DataContext, which a have defined as "var Oracleconnection = new DataContext(connectionString)".



I have it set up pretty much just like this https://docs.appeon.com/dwconverter2019r2/api_reference/DWNet.Data/ModelAttribute/Class/DataWindowAttribute/DataWindowAttribute.html. i'll post screen shots on a different response under my question. Maybe that will make more sense
  1. Helpful
There are no comments made yet.
Saul Erhmy Accepted Answer Pending Moderation
  1. Tuesday, 11 October 2022 20:29 PM UTC
  2. SnapDevelop
  3. # 2

DataWindow Class. 

My call to the new DataStore, the first call works, second doesn't. The second call should be able to find the correct class because the class is decorated with the attribute and not throw the "No metadata for DataWindow 'myDWattribute' found" error. Maybe I am missing something?

this is my DataContext class. Left it as default. 

Comment
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.