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: Insert new record with SQL From Data on Form
Andrew Fink
Posts: 41
 
Insert new record with SQL From Data on FormYour last visit to this thread was on 1/1/1970 12:00:00 AM
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.
[Reply][Quote]
Dan Carvin
Posts: 227
 
Re: Insert new record with SQL From Data on FormYour last visit to this thread was on 1/1/1970 12:00:00 AM
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.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Insert new record with SQL From Data on FormYour last visit to this thread was on 1/1/1970 12:00:00 AM
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.

[Reply][Quote]
Dan Carvin
Posts: 227
 
Re: Insert new record with SQL From Data on FormYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Aug 09 1:38 PM
What is the difference between using ShowViewForRecord and DoInvoke "Form","Family:formname" ?
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Insert new record with SQL From Data on FormYour last visit to this thread was on 1/1/1970 12:00:00 AM
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.


[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 2:08:16 PM