Hi
I have been following a post by nikhulion and answered by bijeesh. I am a novice at C# and would like to know how to actually compile and run the class resolution by bijeesh.
Code included here with error on assembly; Urgent assistance required please :-)
private void WriteXmlMethod()
{
string constring = ConfigurationManager.ConnectionStrings ["YourConnectionString"].ToString();
SqlConnection con = new SqlConnection(constring);
con.Open();
string query = "select * from tbl_newsBee";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader dr = cmd.ExecuteReader();
XDocument doc = new XDocument();
XDeclaration declaration = new XDeclaration("1.0", "utf-8", "yes");
doc.Add(declaration);
XElement element1 = new XElement("Newses");
XElement element2 = null;
while (dr.Read())
{
element2 = new XElement("News", new XAttribute("link", dr[2].ToString()), new XAttribute("des", dr[1].ToString()));
element2.Add(dr[3].ToString());
element1.Add(element2);
}
con.Close();
string filename = Server.MapPath("E:/myXmlDoc.xml");
doc.Save(filename);
}
Error that occurred:
The type 'System.ComponentModel.Component' is defined in an assembly that is not referenced.
You must add a reference to assembly:
'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in:
C:\Users\Administrator\Documents\Visual Studio 2010\Projects\WtiteXml.cs
Line: 13
Column: 9
Other Info: TestXML
Edit by EdMan196: Added pre tags/formatting in general and made error message a bit more readable.