Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Wednesday, June 18, 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: error in vb script
Vamsi
Posts: 39
 
error in vb script Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Apr 07 10:08 AM
fiogf49gjkf0d
Dear all

I am trying in to insert values in to the new table which i created under account table

I am trying to insert values in to this table but it is giving error like give values for every field in the table which you created in the data base . i am only giving the values to fields(create user, account id, modify user )which i created in the table but how can i pass the values to the default fields

The code i have written is as shown below

Sub SaveClick(Sender)
Dim objSLXDB
'Dim objRS
Set objSLXDB = New SLX_DB


strSQL = insert into Documents_Submitted values("+ComboBox1.Text+"','"+Picklist1.Text")




objSLXDB.ExecuteSQL strSQL






End Sub


the form has two ctrls combo box and picklist , user select values from combo box( i am populating this comco with acocunt names) and picklist and he will click save button that should got saved in data base


I feel shame because even i am not getting how to insert the values in to table but i tried for retrieve data i am getting it even i tried for deletion i am getting it but i am not getting how to insert


Any body pls help me in this issue


with regards
vamsi

[Reply][Quote]
Jason Huber
Posts: 77
 
Re: error in vb script Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Apr 07 4:43 PM
fiogf49gjkf0d
If you are typing in the code exactly as you have it.. then you are missing some single quotes and another quote at the end...
strSQL = insert into Documents_Submitted values('" + ComboBox1.Text + "','" + Picklist1.Text + "')"

The two fields that will hold the values from combobox1.text and picklist1.text need to be the first two fields in the table. I mean litterally.

This is why I always specify my field names. Always. OK not always, but I mean to

strSQL = "insert into Documents_Submitted (fieldname1, fieldname2) values ('" & ComboBox1.Text & "','" & Picklist1.Text & "')"

This way if you specify them out of order or the dba adds a field by recreating the table (or creates it with his own script) then you will still be OK.

*edited SQL to fix + to & for vbscript
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: error in vb script Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Apr 07 2:29 AM
fiogf49gjkf0d
Quote:
Originally posted by Vamsi

Dear all

I am trying in to insert values in to the new table which i created under account table

I am trying to insert values in to this table but it is giving error like give values for every field in the table which you created in the data base .
strSQL = insert into Documents_Submitted values("+ComboBox1.Text+"','"+Picklist1.Text")


Unless you specify which fields you are writing the values into, SQL will expect values for all the fields on the table.
Instead use the following syntax:

INSERT INTO DOCUMENTS_SUBMITTED (ACCOUNTID, CREATEUSER) VALUES (("+ComboBox1.Text+"','"+Picklist1.Text")

This SQL statement (assuming that there are no other required fields on this table (such as a "DOCUMENTS_SUBMITTEDID") should work.

If you are populating every field on the table, then you could get away without listing the fields that you are writing to, but it is against best practices.
For instance, lets say that there were only 2 columns on the table, and that your SQL statement does work. You write several applications that read/write against that table, and then several years down the road someone else adds a new column to the Table. Now every single SQL Insert statement will break. You will have to revisit every application to correct the situation (Granted, if you added the file you probably would like to change all applications to incorporate the new field, however you would have a limited change window because the SQL statements will actually fail).


[Reply][Quote]
Kris Halsrud
Posts: 88
 
Re: error in vb script Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Apr 07 10:01 AM
fiogf49gjkf0d
Take a look at this post for a better way than using SQL statements, for the reasons already mentioned.

http://www.slxdeveloper.com/page.aspx?action=viewarticle&articleid=76
[Reply][Quote]
Jason Huber
Posts: 77
 
Re: error in vb script Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Apr 07 11:01 AM
fiogf49gjkf0d
Quote:

INSERT INTO DOCUMENTS_SUBMITTED (ACCOUNTID, CREATEUSER) VALUES (("+ComboBox1.Text+"','"+Picklist1.Text")

This SQL statement (assuming that there are no other required fields on this table (such as a "DOCUMENTS_SUBMITTEDID") should work.


I am pretty sure the missing + and single quotes would cause it to fail as well
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: error in vb script Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Apr 07 11:34 AM
fiogf49gjkf0d
Quote:
Originally posted by Jason Huber



I am pretty sure the missing + and single quotes would cause it to fail as well


Next time I will check my syntax before posting, as indeed you are right. I cut and paste his code into mine, but the Purpose of my code was to demonstrate to him the fact that he was not listing the Fields into the SQL statement.

[Reply][Quote]
Jason Huber
Posts: 77
 
Re: error in vb script Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Apr 07 12:11 PM
fiogf49gjkf0d
Quote:
Originally posted by Raul A. Chavez


the Purpose of my code was to demonstrate to him the fact that he was not listing the Fields into the SQL statement.


As was my initial post. I try and follow that rule in production code as well. Good advice.

We could have added:
dont try and use + in vbscript (it is used to add things up - weird for C# guys)
Use parameterized queries (you know ? instead of "'" & something & "'" etc)

but the main point was to specify the fields.
[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): 6/18/2025 8:31:19 AM