1. Bernie Rivera
  2. PowerBuilder
  3. Monday, 12 August 2019 23:35 PM UTC

I am attempting to Save a datawindow.  It works fine if I run it through the PowerBuilder IDE, but when I compile and create an executable i will not save a file.  It returns that it is successful but it does not save the file.  Code snippet below:

li_ret = lds_report.SaveAs("C:\Temp\COM\rpt_4a2359a7-7c96-45d9-9416-6cabb3f82301.csv", CSV!, false)

 

What could be the problem?  I have been struggling all day with this.  Looking at help, internet, dependencies, examples, and anything else I could think of and it does not make sense why it only works when running from the IDE.  Any help would be greatly appreciated, thanks.

 

Bernie

Accepted Answer
Bernie Rivera Accepted Answer Pending Moderation
  1. Tuesday, 13 August 2019 20:31 PM UTC
  2. PowerBuilder
  3. # Permalink

FINAL UPDATE.

Ok, turns out that PowerBuilder 2019 does not like when you import an older PBL.  It doesn't complain it just cause the datawindows contained inside it to fail.

I exported the old datawindows and imported them into the main pbl and all works as expected.  Frustrating that it took me so long to figure it out, but I am glad it ended with an understanding of the situation. 

Thanks to everyone for your suggestions.

Bernie

Comment
  1. Roland Smith
  2. Wednesday, 14 August 2019 12:53 PM UTC
DataWindows have source and compiled versions in the PBL just like an object or window has.
  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 19 August 2019 15:43 PM UTC
  2. PowerBuilder
  3. # 1

Ok....time to start from scratch.

1. In the EXE, is the app connected to the database?
2. If so, does the connected user have READ rights to the database?
3. Is the Retrieve command even getting called?
4. If so, what is the return code?
5. IF an error occurs, are you capturing everything in the DBERROR event?
6. If so, what is th error nessage?


Later -

Olan

 

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 14 August 2019 11:53 AM UTC
  2. PowerBuilder
  3. # 2

Hi Bernie; 

   I suspect that your issue might be corrected as well by editing the DW source and changing the "release" number to "19" &  then save.

Regards ... Chris

Comment
There are no comments made yet.
Bernie Rivera Accepted Answer Pending Moderation
  1. Tuesday, 13 August 2019 20:13 PM UTC
  2. PowerBuilder
  3. # 3

UPDATE:  OK, I am making progress on figuring out what the issue is.  I did not consider that fact, that I imported the datawindows from from an older version of PowerBuilder, to be a factor with this issue but it seems to be directly related to the problem.   

Roland Smith's comment about the PBD file made me think that maybe the datawindows were causing the problems.   I decided to create a datawindow from scratch and lo and behold that one worked just fine.  So now I am faced with the mystery of why the older datawindows don't work. It still does not make sense why it works fine in the IDE but not the executable.  Below is what I have found out when running from the executable:

  1. An unmodified older datawindow fails on the retrieve.
  2. An older datawindow that I opened, modified and saved also fails.
  3. Newly created datawindow, successfully retrieves and the saveas also succeeds in saving the file.

 

Why does it have a problem with the older datawindows that I imported in?

Even opening, modifying and saving the older datawindow in PowerBuilder 2019 doesn't seem to help at all.

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 13 August 2019 18:15 PM UTC
  2. PowerBuilder
  3. # 4

Make sure the datawindow was actually included in the executable. If you are not creating a PBD, you will probably need a .PBR file.

Comment
  1. Bernie Rivera
  2. Tuesday, 13 August 2019 19:06 PM UTC
Thanks, for the reply, but it has the PBD file. As a matter of fact, I am running it from the same directory that it was compiled in. It will run fine in the IDE but not when I run the executable. It is very puzzling.
  1. Helpful
There are no comments made yet.
Bernie Rivera Accepted Answer Pending Moderation
  1. Tuesday, 13 August 2019 17:26 PM UTC
  2. PowerBuilder
  3. # 5

UPDATE ON MY ISSUE:  It looks like I was focused on the SaveAs, but the problem actually is in the retrieve.  It seems to be failing.  I don't know if this is good news or just different bad news.  Hopefully it is at least helpful in figure out the true underlying problem.

Anyway, I don't think it has anything to do with SQL connection since it runs a previous inline SQL statement just fine before I even set up the datawindow code.  The return code on the retrieve is a -1.  The sqlca does not show any errors, though.  A code snippet is below:

lds_report = create datastore
lds_report.dataobject = ls_reportname
lds_report.SetTransObject(sqlca)
li_ret = lds_report.Retrieve()

Comment
There are no comments made yet.
Ronnie Po Accepted Answer Pending Moderation
  1. Tuesday, 13 August 2019 16:37 PM UTC
  2. PowerBuilder
  3. # 6

Based on the variable name, it looks like lds_report is a datastore rather than a datawindow.

When running as an executable, are you sure that it is properly instantiated and contains data?

 

 

Comment
  1. Bernie Rivera
  2. Tuesday, 13 August 2019 16:44 PM UTC
Thanks for the response. The variable is a datastore but what it is referencing is a datawindow report. Like I said it works fine when running from the PowerBuilder IDE. Should I bejusing a different object type?
  1. Helpful
  1. Ronnie Po
  2. Tuesday, 13 August 2019 19:21 PM UTC
A datastore should be fine, but since it's not visible like a DW, you won't see if it fails to instantiate or is referencing a dataobject that's missing at runtime. Just for testing purposes, can you perform the same operation using a datawindow control placed on a window or userobject? That way you can see what's going on...
  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Tuesday, 13 August 2019 16:31 PM UTC
  2. PowerBuilder
  3. # 7

Try closing the LOG file before executing the SAVE AS and see if that works.
Sometimes an open file will mark the folder as IN USE, which can interfere with other folder-related operations.


Olan

Comment
  1. Bernie Rivera
  2. Tuesday, 13 August 2019 17:28 PM UTC
Thanks, it turns out it is failing on the retrieve. Please read my update on this issue below.
  1. Helpful
  1. Olan Knight
  2. Tuesday, 13 August 2019 19:42 PM UTC
Failing on the retreive means that nothing is in the DW, so nothing will be saved.



Try creating a DW on the object and using that instead of the datastore. That way you can put MessageBoxs at various critical points, and you can get a detailed message from the DBERROR event. You can also see the run-time SQL from the SQLSYNTAX. Those two bits of data should allow you to resolve why the Retrieve is failing at runtime.



Olan
  1. Helpful
There are no comments made yet.
Bernie Rivera Accepted Answer Pending Moderation
  1. Tuesday, 13 August 2019 14:54 PM UTC
  2. PowerBuilder
  3. # 8

Yes, I have tried running it as admin, and I am not sure why the executable would have any different permissions than the IDE since the are on the same computer saving to the same folder. It is a manually created folder that doesn't have any permission restrictions. It works fine running from the PB IDE, but the executable does not save the datawindow. I don't think that it can be a permission issue since the app is writing a log file to the same folder. The log file gets written when running the executable but the datawindow does not save. That is how I know that the SaveAs method is returning a 1 even though it doesn't save anything. It just doesn't make sense.

Oh, I forgot to mention, I am using PowerBuilder 2019.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 12 August 2019 23:40 PM UTC
  2. PowerBuilder
  3. # 9

Hi Bernie;

  Make sure that your app has write privileges to that folder and that this location is not write protected.

  Have you tried running your PB App as ADMIN?

Regards... Chris

Comment
  1. Bernie Rivera
  2. Tuesday, 13 August 2019 16:45 PM UTC
Thanks, but it is able to save a log file to that folder so permissions are not an issue. Read my previous response.
  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.