Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Thursday, May 22, 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!
 Data & Imports Forums - T-SQL & Queries
Forum to discuss general T-SQL questions and help with queries related to SalesLogix data. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to T-SQL & Queries | New ThreadView:  Search:  
 Author  Thread: Append Comma to field causing "E_Fail Status' error
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Append Comma to field causing "E_Fail Status' errorYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Oct 07 7:19 AM
I am looping through a recordset in an attempt to append a comma to the end of all records in a field. The code is below... If I remove the "," from the end of the code being updated it runs fine.. How can I accomplish this? I want to update every county field in the table with a comma on the end of it.
Thanks

Set objRS = objSLXDB.GetNewRecordSet
strSQL = "Select County,C_RSM_STATE_CROSSREFID from C_RSM_STATE_CROSSREF order by C_RSM_STATE_CROSSREFID"
objRS.Open strSQL, objSLXDB.Connection

Do while not objRS.eof
Set objRS2 = objSLXDB.GetNewRecordSet
strSQL2 = "Select County from C_RSM_STATE_CROSSREF where C_RSM_STATE_CROSSREFID='" & objRS("C_RSM_STATE_CROSSREFID") & "'"
objRS2.Open strSQL2, objSLXDB.Connection
If not objRS2.eof then
objRS2.Fields("County").Value = objRS("County") & ","
objRS2.Fields("MODIFYUSER").Value = Application.BasicFunctions.CurrentUserID
objRS2.Fields("MODIFYDATE").Value = Now
objRS2.Update
End If
Set objRS2 = Nothing
objRS.movenext
Loop
[Reply][Quote]
Jason Buss
Posts: 382
 
Re: Append Comma to field causing "E_Fail Status' errorYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Oct 07 10:05 AM
I'm not sure if this will help, but it would be very easy to try. Instead of passing the string, try using the ASCII code for a comma

Like:

objRS2.Fields("County").Value = objRS("County") & Chr(44)
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Append Comma to field causing "E_Fail Status' errorYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Oct 07 11:42 AM
I wonder if maybe resources aren't getting cleaned up and a leak is causing the problem? Only that that stands out in that area is to explicitly close the objRS2 recordset in each interation of the loop before setting it to Nothing. Also, there's not really a need for the inner objRS2 recordset anyway. You could just update the same one you're looping through.

ie:

Set objRS = objSLXDB.GetNewRecordSet
strSQL = "Select * from C_RSM_STATE_CROSSREF"
objRS.Open strSQL, objSLXDB.Connection

Do while not objRS.eof
objRS.Fields("County").Value = objRS("County") & ","
objRS.Fields("MODIFYUSER").Value = Application.BasicFunctions.CurrentUserID
objRS.Fields("MODIFYDATE").Value = Now
objRS.Update
objRS.movenext
Loop


Also, maybe try doing it as a single SQL update statement?

update c_rsm_state_crossref set county = county+','


Make sense?
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Append Comma to field causing "E_Fail Status' errorYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Oct 07 11:48 AM
Actually I fixed the problem by 'trim'ing the objRS("county") field. I did a msgbox len(objRS("County")) and it was returning the maximum length of the field for some records.. Anyway all is well. Thanks for the tips as always.
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Append Comma to field causing "E_Fail Status' errorYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Oct 07 7:11 AM
I was going to suggest that adding the comma for some records exceeded the field length. Seems you hit upon that.

I am kind of curious, though. Why would you want to append a comma to the end of the county field?
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Append Comma to field causing "E_Fail Status' errorYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Oct 07 8:34 AM
Why indeed would anyone want to do that? I have a utility that allows the admin to assign sales reps to states/counties, then when an opportunity is added or when some other criteria changed the sales rep is autopopulated based on the counties being in the sales reps delimited list. This involves a checkboxlist control and a comma delimited string of counites. I ended up looking for the county and a comma to match a county with a sales rep. So I had bug with counties like Smith and Smithson so I had to add the comma to the search criteria. I had originally coded it with no comma at the end of the stored string of counties so I had to retrofit the data. A little short sighted but that's how it goes sometimes.
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Append Comma to field causing "E_Fail Status' errorYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 Oct 07 9:12 AM
Interesting. Something else you might want to think about is similarly names counties between states. For example there is a Montgomery, AL and a Montgomery, PA. We use counties here as well and have to include the states as well in county listing to differentiate.

John G.
[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): 5/22/2025 8:09:16 PM