Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, August 29, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Persisting ADO Recordset, VB Script Classes between forms?
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Jul 09 8:55 AM
Opp Form A
Create a RS with a bunch of data in it
'persist it' by some mechanism
close the RS and Connection

Account Form C
Do what you have to do to open up the persisted RS
MSGBOX RS.RecordCount

1. RS.SAVE works fine. But am only able to bring back the RS on the same form.
If someone has the 'steps'/code to maybe disconnect this recordset from the connection, then RS.Save

And the code to Dim RS RS.Open "File Path"

THAT Works, I would appreciate it....

But we DON'T want a hard drive persistence.

2. Setting the RS to a Globalinfo doesn't seem to work, if you can Prove it otherwise, great. Let me see the code you are using

This DOES NOT WORK:

Opp Form A
Create a RS with a bunch of data in it
rs.close or not (have tried both methods)
application.globalinfo.ADD "MyRS", RS
close the RS and Connection

Account Form C
DIM RS
SET RS = application.globalinfo.MyRS '''This DOES NOT WORK
MSGBOX RS.RecordCount ''' This DOES NOT WORK:

3. Setting the Array to a Globalinfo probably works, but then it's not a recordset.

Opp Form A
Create a RS with a bunch of data in it
MyArray = GetRows(RS)
application.globalinfo.ADD "MyArray", MyArray

close the RS and Connection

Account Form C
DIM MyArray
MyArray = application.globalinfo.MyArray MSGBOX MyArray(1,1)

4. is there a way to PERSIST a Class? And no, application.globalinfo doesn't work.

5. is there a way to PERSIST an Array?

6. Maybe XML?



Thanks!



RJ Samp
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Jul 09 10:04 AM
How about a "hidden" main view that holds an "Array" of variables.

Thus you could via code locate (or instantiate if not yet used) your hidden form, then load your recordset onto one of the available Variables?


Not pretty, but will do the trick.
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Jul 09 10:35 AM
Well you can application.globalinfo.ADD MyArray and that will persist between forms.

So in your technique
1) Create a MainView Form, but with no Nav Bar button to make it visible to users.
Maybe it's only visible to ADMIN

2. Have to have 1 at least one record stored to it? have a simple table with a few items in it including a USERID field (different users will be storing away THEIR recordset.

3. each users mainview form Collection is their own.....so interact with controls on this form? Maybe a Grid?

IF the Mainview is called
mvGlobalVariables
and the data grid is called grddata
then I can simply

Set mvGlobalVariables.grddata.RecordSet = RS

OR

SET RS = mvGlobalVariables.grddata.RecordSet

???
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Jul 09 11:17 AM
1)
a. It doesn't have to be a "MainView", it could be a Form, but ran as a Main View (e.g. the Add Opportunity Products, which is a good example of how a Recordset is passed back and forth from one view to another).
b. Visible only to Admin is a good thing for Troubleshooting, but should be released to Everyone (so that it is accessible).

2) You don't have to have any data on it, not it has to be linked to any entity. (unless you have need for it, then again, you may want to Persist the recordset into an XML document and then store it into Blob fields. This is if you need to preserve the Recordset across sessions).

3) They don't have to interact with the controls. You can interact with the variables directly. For instance, the Form has a set of Variables for the Recordsets, and then you have a set of Functions (similar to Property Sets/Gets) to pass the Recordset in and Out.

Again, look at how the "Opportunity Product" tab calls the "Add Opportunity Product" (specifically the CallAddOpporunityProductView Sub). It calls the Init Method and passes a Recordset, which is then assigned to a Variable. You could have a Function call SetRecordset and a Function called GetRecordset (if you hav several recordsets, maybe use names such as GetMyObjNameRecorset and SetMyObjNameRecordset) that you would call. So, the code could be something like:

' recordset to be persisted is called: recData1
' Locate (or Create your Main view) into a variable called "globalRecorsetMV"

globalRecorsetMV.Script.SetMyObjNameRecordset recData1 (Calling the Get Method, which stores this recordset on a Variable, or as you stated, if you need to persisted further, you could stream it into a Blob field like the Sales Processes do).


'To retreive th recordset do the opposite:
Set recData1 = goblRecordsetMV.Script.GetMyObjNameRecorset()



Within the Global Form, the code would be something such as:

Dim recObjName

Function GetMyObjNameRecorset
Set GetMyObjNameRecorset = recObjName
'Alternatively, if you are persisting this to the DB, you would place code here to retreive it from there.
End Function

Function SetMyObjNameRecordset(objRec)
Set recObjNAme = objRec
'Alternatively, if you are persisting this to the DB, you would place code here to store it on the DB
End Function



Again, not the most elegant solution, but a manageable one.
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Jul 09 3:03 PM
Yep, I've done this stuff before:

Set objMainView = Application.MainViews.Add("System:Add Opportunity Product", 0, False) 'DNL
objMainView.Caption = Application.Translator.Localize("Add Opportunity Product")
Set objDetail = objMainView.DetailsView

Set objRS = StreamDataFromRS(grdProducts.Recordset)
objDetail.Script.Init objRS, "Edit" 'DNL

So how do you persist the form itself? and keep it Invisible???

That's why when you mentioned the mainview 4 panel object......it would exist in the Forms Collection and available at runtime from ANY form.

Right now our best solution is to simply store an Array into an application.globalinfo.ADD "MyArray", arData() variable.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jul 09 3:38 AM
Quote:
Originally posted by RJ Samp


So how do you persist the form itself? and keep it Invisible???
That's why when you mentioned the mainview 4 panel object......it would exist in the Forms Collection and available at runtime from ANY form.


Yes, the idea is to keep it loaded as a Main view but Hidden (don't show it).
As far as Persistence throughout a session, just keep it loaded as a Main View.

And as stated, if you would like to persist the data across sessions, then you would need to Implement code to save the Recordsets at some point before the Client is closed.
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jul 09 9:46 AM
how do you not show a mainview object (don't do a ShowModal????)?

So basically I
1. Create the Mainview object and don't close it....and trust garbage collection to not destroy it?

2. Populate the data with 1 subroutine.

3. connect to this specific mainview object somehow on another form

4. retrieve the data.

5. Destroy the Mainview object.


So far an Array wins out on this.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jul 09 10:12 AM
I am not saying that the array wouldn't win, it depens on the extent of your needs.
If you are only dealing with one recordset, and have limited need to persist it, yes, I would go with the array.

Regarding the View:
- The "garbage collection" wouldn't destroy it, but a Complete refresh would (CTRL+F5).
- You maintain the data type within the recordset (otherwise you need to store and rebuild the recordset columns and types and potentially cast the values back into the appropriate type).
- If you need to persist across sessions, you could, as stated, end up persistng the recordset into XML documents stored on Blobs within the Database.

As stated, this is a more complex alternative, and I cannot think of a reason to Implement it.

[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jul 09 10:25 AM
Here is another idea, maybe you will like this one better:

- Save the recordset to file (use the GetPersonalDataPath()). [Optionally, you could use specific file names so that you could test if there is a previously saved copy of the recordset]
- Store the Path on a Global Variable [If using specific file names for specific recordsets, there wouldn't be a need to do this]
- You could place your code to load/persist your recordsets into an "Include" script, thus if you have specific names, you could define them in "Constants"

Pros:
- Simple code to write
- No need to parse the Recorset
- Maintain the Recorset schema definition
- Data could be made available for user across sessions (* See note below)

Cons:
- Performance hit on Saving and Loading from file. (Then again, how will that compare to converting the Recordset into and out of an array?)


Note: The recordset could be made available to users across sessions if the files are stored centrally (e.g. a Folder on the Library or Documents Path), and then prefixed with the User's ID. The disadvantage of this approach is that it make loading and saving the recordset slower and dependant on Network connectivity.
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jul 09 1:58 PM
RJS - simply access the globalinfo item directly as such:

Sub Button1Click(Sender)
set Application.GlobalInfo.Item("TimTest") = Application.GetNewConnection
End Sub

Sub Button2Click(Sender)
dim cnx
set cnx = Application.GlobalInfo.Item("TimTest")
End Sub

You dont have to use the Add and Get methods. Note that I dont think it is wise to store a connection in Globalinfo .

Warning - CTRL F5 destroys these objects in GlobalInfo so be careful to check for the existence of your object before trying to access its members.

Timmus
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jul 09 2:12 PM
Timmus:

What he is trying to is disconnect the recordset and then persist it into a Global variable. This doesn't work. So, instead he is (or is planning) into storing the Recordset into a Multi-dimension Array and then storing that Array into the Global Info. He is looking for alternatives.
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jul 09 2:16 PM
Correct, but Tim's approach seems to work. Haven't disconnected yet, but this works just fine within the form:

set Application.GlobalInfo.Item("MyRS") = CCPRS ''' an open valid populated ADO RS.
dim cnx
set cnx = Application.GlobalInfo.Item("MyRS")
MSGBOX cnx.RecordCount '' gives the correct count.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jul 09 2:19 PM
Got it.

I never tried to verify if your issue had a work around, but was working on the "alternatives".

Thanks
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jul 09 2:32 PM
Unfortunately!

That solution Doesn't work across forms........
even did an

Set CCPRS.ActiveConnection = Nothing

first.

So I'm back to arrays (doing nothing fancy).....and your method of a mainview based 'hidden' forms collection member.


RJ Samp
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jul 09 2:33 PM
Did you view my alternate method:

- Persist to File, store the file name on the Global
- Load the recordset from the file


[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jul 09 10:07 PM
Yep we know about that method.....not an option that we really want to explore in this instance.....unique naming of the file, need to delete it after done and prior to storing, etc.

We were really surprised that SLX doesn't have a method of persisting a class or a recordset.....oh well.

Thanks for your help Raul.
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Persisting ADO Recordset, VB Script Classes between forms?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Jul 09 6:35 PM
I just want to clarify that we do indeed store objects in GlobalInfo and that this method works across forms without issue. Globalinfo has nothing to do with forms. Something else is wrong. There is absolutely no difference between storing a disconnected recordset in globalinfo and storing an instance of any other object. It works. I do it often.

Timmus
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 8/29/2025 10:00:22 AM