created rss feed using access database, ASP.NET c#, webservices, this is live sample..
<%@ WebHandler Language="C#" Class="rss" %>
using System;using System.Web;using System.Data.OleDb;using System.Text;using System.Xml;
public class rss : IHttpHandler {
public void ProcessRequest(HttpContext context) {
string sTxt = BuildXmlString(); context.Response.ContentType = "text/xml"; context.Response.ContentEncoding = System.Text.Encoding.UTF8; context.Response.Write(sTxt); } private string BuildXmlString() { string sTitle = "Super Value Deals and Deals of The Day"; string sSiteUrl = "http://www.visli.com"; string sDescription = "Super Value Deals and Deals of The Day"; string sTTL = "60";
System.Text.StringBuilder oBuilder = new System.Text.StringBuilder(); oBuilder.Append(""); oBuilder.Append("
oBuilder.Append("
oBuilder.Append(""); oBuilder.Append(sSiteUrl); oBuilder.Append("");
oBuilder.Append("
oBuilder.Append("
AppendItems(oBuilder);
oBuilder.Append("
public void AppendItems(System.Text.StringBuilder oBuilder) {
string connectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source=c:\\xxxxxxxx\\database\\AbcDB.mdb"; OleDbConnection myOleDbConnection = new OleDbConnection(connectionString); OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand(); string ProdTy = "M2"; string Strsql = "SELECT top 101 * from vcxsd where ProdType='M2'";
myOleDbCommand.CommandText = Strsql; myOleDbConnection.Open();
OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();
myOleDbDataReader.Read(); while (myOleDbDataReader.Read()) { string sTitle = "Super Value Deals and Deals of The Day"; string sLink = "http://www.visli.com/"; string sDescription = "Super Value Deals and Deals of The Day"; string sPubDate = "System.DateTime.Now";
oBuilder.Append("
oBuilder.Append("
oBuilder.Append(""); oBuilder.Append(myOleDbDataReader["NameUrl"].ToString()); oBuilder.Append(""); oBuilder.Append("
oBuilder.Append("
oBuilder.Append("
} }
public bool IsReusable { get { return false; } }
}
Edit this page (you have permission) Edit this page (if you have permission) Report spam Google Docs -- Web word processing, presentations and spreadsheets.
1 comment:
hello,
I'm trying your code, first of all compliments, the code is very
clear and well done.
Unfortunately, I do not have much experience using the CLASS and
I ask you an example to launch your code from a simple default.aspx page.
tank you
GDP
Post a Comment