how to generate rss feed in asp dotnet c#

Oct 2 2015 1:02 AM
i try to generate rss feed using this code ,but it give me a exception at run time as " Cannot attach the file 'c:\users\vikash123\documents\visual studio 2013\Projects\Sample_WebformApplication_RSS\Sample_WebformApplication_RSS\App_Data\aspnet-Sample_WebformApplication_RSS-20150928114944.mdf' as database 'aspnet-Sample_WebformApplication_RSS-20150928114944'."
my code as following
protected void Page_Load(object sender, EventArgs e)
{
string connectionstring = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
SqlConnection sqlcon = new SqlConnection();
sqlcon.ConnectionString = connectionstring;
SqlCommand cmd = new SqlCommand();
cmd.Connection = sqlcon;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT TOP 10 * FROM sample";
sqlcon.Open();
rep.DataSource = cmd.ExecuteReader();
rep.DataBind();
sqlcon.Close();
}
 

Answers (2)