ASPX templates
Version 5.x > ASPX templates > API: run a custom table query View modes: 
User avatar
Member
Member
seanbun - 12/20/2010 10:45:52 PM
   
API: run a custom table query
Hi,

I have defined a query on a custom table. Is there any class on the API I can run the self defined query?

I tried the CustomTableItemProvider class and Getitems. It would run the selectall query by default.

cheers,
Matt

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 12/22/2010 3:47:40 PM
   
RE:API: run a custom table query
Hi,

You can run a custom query if you first create it either manually in the CMS_Query table or through the administration interface. Here is an example:



using CMS.DataEngine;

...

GeneralConnection cn = ConnectionHelper.GetConnection();
DataSet ds = null;

object[,] parameters = new object[1, 3];
parameters[0, 0] = "@UserName";
parameters[0, 1] = "johns";

ds = cn.ExecuteQuery("cms.user.selectbyname", parameters);



Best regards,
Ivana Tomanickova