I am not able to get data from the table using "CustomTableItemProvider" in kentico 8.0 version.

Divya Mawar asked on July 13, 2016 14:16

Here I am using this code, But not getting any items or show object null error : const string customTableClassName = "ESPO.FrameworkStatus"; //var customTableProvider = new CustomTableItemProvider(customTableClassName);

    // Checks if Custom table exists
    var customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);

    if (customTable != null) {
        // Gets the data set according to the parameters
        //var ds = CustomTableItemProvider.GetItems("ESPO.FrameworkStatus", "IsActive=1", "FrameworkStatusValue", -1, null);
        DataSet ds = CustomTableItemProvider.GetItems("ESPO.FrameworkStatus", "IsActive=1", "FrameworkStatusValue", -1, null);
       }

Recent Answers


Trevor Fayas answered on July 13, 2016 15:02

May not answer the "how to get it with CustomTableItemProvider", but i find the QueryInfoProvider works better.

Dataset ds = QueryInfoProvider.ExecuteQuery("ESPO.FrameworkStatus.Selectall", null, "IsActive=1", .....);

All classes have a hidden "selectall" query that you can always call, you can also call your custom queries by name this way as well. Try that.

0 votesVote for this answer Mark as a Correct answer

Divya Mawar answered on July 13, 2016 15:11

I am not getting. It is showing also error, Dataset ds = QueryInfoProvider.ExecuteQuery("ESPO.FrameworkStatus", "IsActive=1", "FrameworkStatusValue", -1, null);

Dataset is not necessary for use.

0 votesVote for this answer Mark as a Correct answer

Saurav Kumar answered on July 13, 2016 15:47

Hi Divya,

Can you please try to make sure that the "IsActive" field and the "FrameworkStatusValue" field exists in the Custom table "ESPO.FrameworkStatus". In case they are present, please try the below code snippet:

var customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName); if (customTable != null)
{
// Gets the data set according to the parameters
DataSet ds = new DataSet(); ds = CustomTableItemProvider.GetItems(customTable.ClassName, "IsActive=1", "FrameworkStatusValue ASC ");
}

Regards,
Saurav

0 votesVote for this answer Mark as a Correct answer

Divya Mawar answered on July 13, 2016 16:01

Sorry, I applied the code but same error is showing.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on July 13, 2016 16:56

I'd check to see if your custom table class name is really ESPO.FrameworkStatus. Seems like this might be the problem.

0 votesVote for this answer Mark as a Correct answer

Divya Mawar answered on July 14, 2016 07:18

The custom table name is correct. The query I have checked on SQl server.

0 votesVote for this answer Mark as a Correct answer

Saurav Kumar answered on July 14, 2016 14:20

Can you attach the screenshot of the Custom Table "General Tab" so that the class name and the table name is visible. Just want to make sure you aren't missing out something.

Regards, Saurav

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.