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}