Listing 14 GetTitles class
// Returns a Recordset listing authors. public class GetTitles : System.Web.IHttpHandler { protected DataSet GetTitlesData(string authorId) { SqlConnection conn = new SqlConnection( ConfigurationSettings.AppSettings["connStr"] ); SqlCommand cmd = new SqlCommand( @"select t.* from pubs..titles t inner join pubs..titleauthor ta on t.title_id = ta.title_id where ta.au_id = @AuthorId", conn); cmd.Parameters.Add("@AuthorId", SqlDbType.VarChar); cmd.Parameters["@AuthorId"].Value = authorId; SqlDataAdapter adap = new SqlDataAdapter(cmd); DataSet dataSet = new DataSet(); adap.Fill(dataSet); return dataSet; } #region Implementation of IHttpHandler public void ProcessRequest(System.Web.HttpContext context) { string authorId = context.Request.QueryString["au_id"]; DataSet dataSet = GetTitlesData(authorId); XmlDocument xmlDoc = ADOUtility.ConvertDataSetToXmlDocument( dataSet ); context.Response.ContentType = "text/xml"; context.Response.CacheControl = "no-cache"; context.Response.Write( xmlDoc.OuterXml ); } public bool IsReusable { get { return true; } } #endregion }