XML error with Net 2.0
-
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