API Questions on Kentico API.
Version 6.x > API > QueryRepeater not accept QueryParametrer View modes: 
User avatar
Member
Member
roman_kubanek - 10/24/2011 2:51:30 AM
   
QueryRepeater not accept QueryParametrer
Hi

I want to use QueryRepeater and to have option work with QueryParameters collection
programatically. But QueryRepeater don't accept this. Here is Example:

QueryDataParameters qdp = new QueryDataParameters();
qdp.Add(new DataParameter("@GroupID", 1));
this.QueryRepeater1.QueryParameters = qdp;

For example I need use this parameter(@GroupID) in some query like this

SELECT [WorkgroupName]
,[WorkgroupNodeId]
,[OwnerId]
,[SiteID]
,[GroupID]
,[DepartmentID]
FROM [dbo].[LION_group_departments] WHERE GroupID = @GroupID

This is query to Custom Table. Exists some way how to do it?
Thanks for your response

Roman Kubanek

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/25/2011 6:13:35 AM
   
RE:QueryRepeater not accept QueryParametrer
Hi,

could you please try to use below code to pass parameters into the query repeater?

object[,] parameters = new object[1, 3];
parameters[0, 0] = "@ID";
parameters[0, 1] = 17;

this.QueryRepeater1.QueryParameters = parameters;


With above code you should be able to achieve your goal.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
roman_kubanek - 10/25/2011 9:09:12 AM
   
RE:QueryRepeater not accept QueryParametrer
Hi Ivana

Thanks for your answer. But problem is it produce this known error:

Cannot implicitly convert type 'object[*,*]' to 'CMS.SettingsProvider.QueryDataParameters'

What I want is to develop solution which extends your Kentico intranet solution. And I want maximally use what CMS offer (query,transformation) for better scalability and usability in other Intranet solutions. My question is, here is some other option discus about this, because this way (forum) is too slow?

All the best

Roman Kubanek

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/27/2011 8:23:07 AM
   
RE:QueryRepeater not accept QueryParametrer
Hi,

yes, you are right. The API was changed in a 6.0 version. I am sorry for confusion.

Here is the working example
                
// Prepare parameters structure
QueryDataParameters parameters = new QueryDataParameters();
parameters.Add("@ItemID", null);
parameters.Add("@WhereCond", null);
repItems.QueryParameters = parameters;

// Example of query execution
SqlHelperClass.ExecuteQuery("query.code.name", parameters, null, null);


I hope it will work for you.

Best regards,
Ivana Tomanickova