"Vijay Kr. Poriya" wrote:
> Hi All,
> Please let me know how i can display the query results fetched from crm
> database into Datagrid directly.
> Any help is appreciated.
I assume that you are referring to using the CRMAccount.Retrieve method
This method will retrieve information on a single Account - So I'm not sure
why you would want to display it in a Datagrid.
A more likely method to display in a DataGrid would be one of the other
Retrieve methods like CRMAccount.RetrieveByPrincipal. See
This method will return the results as XML using the columnSetXML you define
as a parameter in the method.
There are probably a lot of ways to read that XML. One approach is to use
the System.IO.StringReader class to read the string and return a
System.IO.TextReader object. A DataSet can then read that TextReader object
to create a DataSet to be displayed in the DataGrid.
The tricky part is that even if any of the columns defined in the
ColumnSetXML are null, the method will not include those columns. This might
cause unexpected results for your DataGrid.
One solution to this problem is to pre-define the schema for the dataset
using an XSD file. This also allows you to specify the data types so that
they are not all defaulted to System.String.
The end result would be something like:
String resultXml = CRMAccount.RetrieveByPrincipal(Caller, Principal,
DataSet ds = new DataSet();
There is instructor-led training available on using the Microsoft CRM Class
Library methods. See Course #8308 Extending Microsoft CRM with .NET.
Information on this course is available at
There is also a supporting course #8309 called .Net Tools to Extend CRM that
includes more discussion of supporting technologies.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at