Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Wednesday, August 27, 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: Add records to an existing datagrid from a different sql string
SLX_Novice
Posts: 246
 
Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 9:57 AM
Hi all.

I have a datagrid that I populate using the following code:

Dim strSQL

With Datagrid1

strSQL = "Select * from myTable"

.SQL.Text = strSQL

With .Columns

If (.Count > 0) Then

For i = 0 To .Count - 1

.Item(0).Delete
Next

End If

End With

.Refresh

End With


I want to be able to also add some records from a completely different sql string, for example,

strSQL1 = "Select * from myTable2"

and have that data also included in the datagrid. I just don't know what the correct code is to do that? Is it .SQL.Text.Add ? or .SQL.Text.Append?

Thank you in advance!
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 12:27 PM
simply union the sql together before populating the grid:

strSQL = "Select * from myTable UNION Select * from myTable2"

as long as the columns line up you are good - in other words you likely need to replace * with a list of columns.

Timmus
[Reply][Quote]
SLX_Novice
Posts: 246
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 3:27 PM
Hi Timmus. Thanks for the reply. I tried your suggestion and I got an error stating it couldn't find the table: C_Facility_Price_A


strSQL = "Select Contract, PrintMedia_ItemNumber, Item_Number, UnitsPerCase, Contract_Price_Case FROM C_FACILITY_PRICE_A WHERE ACCOUNTID ='" & application.BasicFunctions.CurrentAccountID & "' UNION Select Contract, PrintMedia_ItemNumber, Item_Number, UnitsPerCase, Contract_Price_Case FROM C_GPO_IND_PRICING WHERE ACCOUNTID ='" & application.BasicFunctions.CurrentAccountID & "'"

Should I be adding a paranthesis somewhere before or after the UNION portion?
[Reply][Quote]
SLX_Novice
Posts: 246
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 3:31 PM
This is the error I get:

The column prefix 'C_Facility_Price_A' does not match with a table name or alias name used in the query.
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 3:33 PM
Try connecting to a query tool like SQL Management Studio as sysdba and test the following:

Select Contract, PrintMedia_ItemNumber, Item_Number, UnitsPerCase, Contract_Price_Case FROM C_FACILITY_PRICE_A WHERE ACCOUNTID ='fakeid'
UNION
Select Contract, PrintMedia_ItemNumber, Item_Number, UnitsPerCase, Contract_Price_Case FROM C_GPO_IND_PRICING WHERE ACCOUNTID ='fakeid'

Does it parse? Does C_Facility_Price_A actually exist and is it owned by sysdba?

Timmus
[Reply][Quote]
SLX_Novice
Posts: 246
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 3:47 PM
Ok. I typed the following in SQL Query Analyzer in SQL Server Enterprise Manager:

Select Contract, PrintMedia_ItemNumber, Item_Number, UnitsPerCase, Contract_Price_Case FROM sysdba.C_FACILITY_PRICE_A WHERE ACCOUNTID ='A6UJ9A000E2R'
UNION
Select Contract, PrintMedia_ItemNumber, Item_Number, UnitsPerCase, Contract_Price_Case FROM sysdba.C_GPO_IND_PRICING WHERE ACCOUNTID ='A6UJ9A000E2R'

And it gave me the desired results.

I then changed my script in the Architect to be the following:

strSQL = "Select Contract, PrintMedia_ItemNumber, Item_Number, UnitsPerCase, Contract_Price_Case FROM sysdba.C_FACILITY_PRICE_A WHERE ACCOUNTID ='" & application.BasicFunctions.CurrentAccountID & "'"
strSQL = strSQL & " UNION"
strSQL = strSQL & " Select Contract, PrintMedia_ItemNumber, Item_Number, UnitsPerCase, Contract_Price_Case FROM sysdba.C_GPO_IND_PRICING WHERE ACCOUNTID ='" & application.BasicFunctions.CurrentAccountID & "'"

And I got the same error stating C_Facility_Price_A does not exist etc.
[Reply][Quote]
SLX_Novice
Posts: 246
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 3:50 PM
When I use just one of the sql strings they work fine, it's when I combine both with UNION that I get that error.
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 3:52 PM
If you can run the SQL via the Administrator | Execute SQL then it is not a SQL parsing issue. Maybe you need to alias your table to match what the Grid is looking for?

Timmus
[Reply][Quote]
SLX_Novice
Posts: 246
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 3:59 PM
But when I run each statement individually, in other words, I comment everthing after the UNION (I do not include the UNION) it shows me the results in the client, when I comment everything before the UNION it gives me the correct results.

I simply want both sets of results to be displayed, I must be using wrong syntax with the UNION?
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 4:07 PM
Have you tested the UNION syntax via Execute SQL. Maybe your version of SLX does not support UNION. I have been using UNION in SalesLogix for years so this would suprise me but I suggest checking.

Timmus
[Reply][Quote]
SLX_Novice
Posts: 246
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 4:14 PM
We are using SLX version 7.2.1

I ran the SLXProfiler and this is what I got:

---------- Client SQL ---------
Select Contract, PrintMedia_ItemNumber, Item_Number, UnitsPerCase, Contract_Price_Case FROM sysdba.C_FACILITY_PRICE_A WHERE ACCOUNTID ='A6UJ9A000E2R' UNION Select Contract, PrintMedia_ItemNumber, Item_Number, UnitsPerCase, Contract_Price_Case FROM sysdba.C_GPO_IND_PRICING WHERE ACCOUNTID ='A6UJ9A000E2R'
---------- Executed SQL ----------
Select C_FACILITY_PRICE_A.Contract, C_FACILITY_PRICE_A.PrintMedia_ItemNumber, C_FACILITY_PRICE_A.Item_Number, C_FACILITY_PRICE_A.UnitsPerCase, C_FACILITY_PRICE_A.Contract_Price_Case FROM sysdba.C_FACILITY_PRICE_A WHERE C_FACILITY_PRICE_A.ACCOUNTID ='A6UJ9A000E2R' UNION Select C_GPO_IND_PRICING.Contract, C_GPO_IND_PRICING.PrintMedia_ItemNumber, C_GPO_IND_PRICING.Item_Number, C_GPO_IND_PRICING.UnitsPerCase, C_GPO_IND_PRICING.Contract_Price_Case FROM sysdba.C_GPO_IND_PRICING WHERE C_FACILITY_PRICE_A.ACCOUNTID ='A6UJ9A000E2R'


The only thing I noticed was that the UNION part did not start in a new line, I don't know if that makes a difference?
[Reply][Quote]
SLX_Novice
Posts: 246
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 4:27 PM
I tried something different I took of the WHERE on both lines (i.e. display everthing regardless of the ACCOUNTID) and it displayed data.

Could my where clause be wrong?
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 5:00 PM
Ah ha - it appears the parser is auto appending the table name as a prefix in your where clause. Try aliasing your statement like this:

strSQL = "Select A.Contract, A.PrintMedia_ItemNumber, A.Item_Number, A.UnitsPerCase, A.Contract_Price_Case FROM sysdba.C_FACILITY_PRICE_A A WHERE A.ACCOUNTID ='" & application.BasicFunctions.CurrentAccountID & "'"
strSQL = strSQL & " UNION"
strSQL = strSQL & " Select B.Contract, B.PrintMedia_ItemNumber, B.Item_Number, B.UnitsPerCase, B.Contract_Price_Case FROM sysdba.C_GPO_IND_PRICING B WHERE B.ACCOUNTID ='" & application.BasicFunctions.CurrentAccountID & "'"

Timmus
[Reply][Quote]
SLX_Novice
Posts: 246
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 8:18 PM
That was it Timmus, thanks for all your help and patience!
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Jan 09 8:22 PM
Happy to help, Fabian. Happy New Year!

Timmus
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Jan 09 8:39 AM
Careful on the Alias', the parser will prepend those for you......

You'll need to explicitly spell them out, same as a SQL statement from a DataGrid.....

[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Add records to an existing datagrid from a different sql stringYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Jan 09 8:39 AM
Careful on the Alias', the parser will prepend those for you......

You'll need to explicitly spell them out, same as a SQL statement from a DataGrid.....

[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/27/2025 10:19:47 PM