How to display XML string returned by CRM Accountobject.retrive me

Hi All,

Please let me know how i can display the query results fetched from crm 
database into Datagrid directly.

Any help is appreciated.


0
Utf
2/21/2005 6:03:02 AM
crm 35858 articles. 1 followers. Follow

1 Replies
486 Views

Similar Articles

[PageSpeed] 25


"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.
> 
> 

Vijay -

I assume that you are referring to using the CRMAccount.Retrieve method 
documented at 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CrmSdk1_2/htm/v1d2crmaccountretrievemethod.asp

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 
http://msdn.microsoft.com/library/en-us/CrmSdk1_2/htm/v1d2crmaccountretrievebyprincipalmethod.asp?

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, 
ColumSetXML);
DataSet ds = new DataSet();
ds.ReadXmlSchema(HttpContext.Current.Server.MapPath("MyAccount.xsd"));
ds.ReadXml(new StringReader(resultXml));

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 
http://www.microsoft.com/learning/syllabi/en-us/8308afinal.mspx

There is also a supporting course #8309 called .Net Tools to Extend CRM that 
includes more discussion of supporting technologies.

See http://www.microsoft.com/learning/syllabi/en-us/8309afinal.mspx

HTH
Jim

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 
http://www.microsoft.com/info/cpyright.htm

0
Utf
2/23/2005 5:05:04 PM
Reply:

Similar Artilces: