8/29/2025 1:33:37 PM
|
|
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!
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.
|
|
|
|
Insert new record with SQL From Data on Form
Posted: 25 Aug 09 10:45 AM
|
How do I go about using SQL/vbscript to insert a new record into a table other than the one the form uses? I have a couple labels and edit boxes that I would like to build an insert statement with then execute the sql when a button is pressed. I think I use the ExecuteSQL function but I need some clarification on how to do this. Thanks Andrew
p.s. Also let me know if this has been covered some where else on the forum. I'm sure it has if you know where it is please point me in the right direction. Thanks. |
|
|
|
Re: Insert new record with SQL From Data on Form
Posted: 25 Aug 09 2:39 PM
|
The prefered way seems to be to use ADO to create a record set, and add it to the table.
In Architect, do a search on All Scripts for the string ".AddNew" and you'll find several examples you can use to model your insert after. |
|
|
|
Re: Insert new record with SQL From Data on Form
Posted: 26 Aug 09 2:12 PM
|
The preferred way would be to Create a Data Bound form and then just let the system Add/Edit the records into the DB.
Lacking that approach, you could indeed use ADO to Insert the data into the database.
The ExecuteSQL function that you were looking at is part of an Wrapper Object built around ADO.Net, you would need to instantiate that object so that you could then call the ExecuteSQL, otherwise you could just instantiate your own ado connection object and use the Execute function:
e.g. 1) Using the Include Script: Dim objSLX
Set objSLX = new SLX_DB objSLX.ExecuteSQL "INSERT YOUR SQL STATEMENT HERE....." Set bojSLX = Nothing
or
2) Using ADO connection directly Dim acon
Set acon = Application.GetNewConnection() 'This will return a ADO connection with all the settings for SLX 'Check if open, if not open it: acon.Open acon.Execute "INSERT YOUR SQL STATEMENT HERE....." Set acon = Nothing
Now, as stated, if you create a Data Form bound to the table that you are interested on, and then bound each field on the form as necessary, then you could call the Form in Insert mode: e.g. Application.BasicFunctions.ShowViewForRecord "TABLENAME", "VIEWNAME", "" 'The last parameter would be the ID of the record, for it to be in insert mode, you pass it a blank ID.
|
|
|
| |
|
Re: Insert new record with SQL From Data on Form
Posted: 27 Aug 09 1:44 PM
|
How could you select which record to "View" when using the "DoInvoke" function?
I have never used it, not sure how it works. I would suggest you stick to the ShowViewForRecord as it is part of the APIs built by SAGE and would have a more predictable result between versions.
|
|
|
|
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!
|
|
|
|
|
|
|
|