Error 0x80041110 QueryByAttribute must specify a non-empty attribute array in CRM

This error occurs when using the QueryByAttribute class we are not setting the Attributes and Values Property.

 

Just like the below code

 

Say we want to have the names of all the accounts,

 

ColumnSet myCols=new ColumnSet();

            myCols.Attributes=new string[] {“name”};

   QueryByAttribute myQA = new QueryByAttribute();

            myQA.EntityName = EntityName.account.ToString();

            myQA.ColumnSet = myCols ;           

            BusinessEntityCollection myBCColl2= myService.RetrieveMultiple(myQA);

 

However we will get error in this case because we haven’t specified Attributes and Values property. So we need to specify those properties.

 

            myQA.Attributes = new String[] { “statuscode” };

            myQA.Values=new object[] {“1”};

 

Otherwise we could use QueryByExpression class for that

 

            ColumnSet myCols=new ColumnSet();

            myCols.Attributes=new string[] {“name”};

 

            QueryExpression myQE = new QueryExpression();

            myQE.EntityName = EntityName.account.ToString();

            myQE.ColumnSet = myCols;

 

            BusinessEntityCollection myBCColl1 = myService.RetrieveMultiple(myQE);

 

 

Bye ..


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

1 thought on “Error 0x80041110 QueryByAttribute must specify a non-empty attribute array in CRM”

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s