sorry for late reply, just received your replies now, and sorry for my bad explanation
here is the exactly the case I have:
I have about 25 SQL tables, so I have to set the criteria dynamically for each one, I don't want to show table names in code, at the same time I have to send table name and criteria as parameters
as in attached pictures, the browse tab lists what user wants to browse, once clicked I set table alias name, for example it is BROWSE_INDEX_DRIVERS for DRIVERS table, then criteria maker shows up to set the criteria according to user needs
once OK clicked I get 2 vars (vary from table to another and according to what criteria user have made)
2- selected fields names like: SELECT [Company],[DriverID],[DrivingLicense]
3- conditions like: WHERE [DriverID] = 'DRV000004'
1- the first var is table alias(we have it before when user clicked the listview item)
I pass them to jRDC to run stored procedure with 3 parameters
sql.dynamicquery = EXECUTE ExecDynamic ? , ? , ?
the server executes the query and I get result set:
PROCEDURE [dbo].[ExecDynamic] @tablealias nvarchar(100), @selfields nvarchar(max), @criteria nvarchar(max)
declare @sql nvarchar (max);
declare
@table nvarchar(100);
set
@table = dbo.GetTableNameFromAlias (@tablealias) -- get real table name from alias lookup function
set @sql = @selfields + ' FROM ' +
@table + ' ' + @criteria
EXECUTE sp_executesql @sql