ASPX templates
Version 4.x > ASPX templates > Display custom data with parameter using custom query View modes: 
User avatar
Member
Member
Ed - 4/29/2009 10:30:28 PM
   
Display custom data with parameter using custom query
I would like to run a custom query using a parameter. I found 2 articles that explain the solution here on the Kentico DevNet. However, the 2nd article is a little confusing to understand. Can someone please help explain #2?

1. http://devnet.kentico.com/Knowledge-Base/portalengine/Displaying-custom-data-from-a-database.aspx

2. http://devnet.kentico.com/Knowledge-Base/API-and-Internals/Running-the-custom-query-using-parameters.aspx

Thanks in advance!

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 5/18/2009 8:03:32 AM
   
RE:Display custom data with parameter using custom query
Hi Ed,

For example: if you would have a SQL query (saved in CMSSiteManager -> Development -> Document types -> edit document type -> Queries) with a parameter e.g.:
SELECT LastName FROM Employees WHERE id = @ID

Then you could set the value of @ID parameter when calling the query by mentioned approach:
object[,] parameters = new object[1, 3];
parameters[0, 0] = "@ID";
parameters[0, 1] = 17;

It means that it valuates the @ID parameter by 17 in this case.

I hope it could help you.

Best regards,
Helena Grulichova

User avatar
Member
Member
Louis - 8/20/2013 8:01:32 PM
   
RE:Display custom data with parameter using custom query
Hi Kentico,

I have a question, as the parameter object only need 2 place to hold name and value:

[0, 0] for Name
[0, 1] for value

why we need to construct it with [1,3]? Shouldn't it be [1,2] instead?

Thanks,
Louis

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 8/22/2013 2:49:18 AM
   
RE:Display custom data with parameter using custom query
Hello,

This is pretty old thread - in those times the third place was reserved for the type specification where you could add TypeOf for given object.

Best regards,
Juraj Ondrus