Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. XML error with Net 2.0

XML error with Net 2.0

Scheduled Pinned Locked Moved ASP.NET
helpxmljsonquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rturner003
    wrote on last edited by
    #1

    I did not have a problem when running in Framework 1.1 but since I am running in 2.0 I am getting the following error: SqlException (0x80131904): XML parsing error: Switch from current encoding to specified encoding not supported. The code I am using is: (snippet) - [XmlRoot ("pledges")] /// /// Summary description for pledge. /// public class pledge { private string strName; private string strAddress1; private string strAddress2; private string strTown; private string strPostcode; private string strEmail; private string strTelephone; private int intAmount; private int intGiftAid; private string strMessage; [XmlAttribute (AttributeName = "name")] public string Name { get { return this.strName; } set { strName=value; } } [XmlAttribute (AttributeName = "address1")] public string Address1 {.............. and the routine to process: public void sponsorship(pledge details) { MemoryStream memoryStream = new MemoryStream(); XmlSerializer serlizer = new XmlSerializer(typeof(pledge)); SqlCommand cmdInsert; SqlParameter paramReturnValue; string strXML = null; int intSuccess; try { XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); serlizer.Serialize(xmlTextWriter, details); memoryStream = (MemoryStream)xmlTextWriter.BaseStream; strXML = UTF8ByteArrayToString(memoryStream.ToArray()); }catch (Exception e) { System.Console.WriteLine(e); } SqlConnection conPledge = new SqlConnection(Settings.GetConfigValues("appSettings","databaseConnectionString")); cmdInsert = new SqlCommand("p_xmlPledgeInsert",conPledge); cmdInsert.CommandType = CommandType.StoredProcedure; cmdInsert.Parameters.Add("@strXML",SqlDbType.NText); cmdInsert.Parameters["@strXML"].Value=strXML; paramReturnValue = cmdInsert.Parameters.Add("ReturnValue", SqlDbType.Int); paramReturnValue.Direction=ParameterDirection.ReturnValue; conPledge.Open(); cmdInsert.ExecuteNonQuery(); intSuccess = Convert.ToInt16(cmdInsert.Parameters["ReturnValue"].Value); conPledge.Close(); } } I wonder if you can help me? Robert T Turner

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups