C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Get Data from SQL Server Database in XML Format


Posted Date: 04 Jun 2004    Resource Type: Articles    Category: .NET Framework
Author: ShajanMember Level: Silver    
Rating: 1 out of 5Points: 4





public System.Xml.XmlReader GetDataInXMLFormat()
{
SqlConnection objCon=new SqlConnection();
SqlCommand objCmd=new SqlCommand();
System.Xml.XmlReader xmlReader=null;

//You can add your own try block here to determine any error occured

objCon.ConnectionString="Your Connection String without porvider name;
objCon.Open();
objCmd.Connection=objCon;
objCmd.CommandText="Your Stored Procedure Name that contains For XML Auto statement";
objCmd.CommandType=CommandType.StoredProcedure;
//if stored procedure contains parameter
SqlParameter objParamSeriesID =new SqlParameter("@ParameterName",OleDbType.Integer);
objParamSeriesID.Value="ParameterValue";
objCmd.Parameters.Add(objParamSeriesID);
//Otherwise u can skip the previous three lines
xmlReader=objCmd.ExecuteXmlReader();
return xmlReader;

//You can add your own catch block here to determine any error occured
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Using base to Access a Hidden Name
Previous Resource: What is a Assembly and Whats the difference between private and shared assemblies
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use