I, Me, Myself

My photo
Hyderabad, Hindhu/AndhraPradesh, India
CoOl,jOvial,strAight fOrward

Search

Tuesday, July 12, 2011

Xml Converting For Serilization

 public bool InsertMarks(MarksDTO marksdto)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(MarksDTO));
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            try
            {
                serializer.Serialize(stream, marksdto);
                stream.Position = 0;
                doc.Load(stream);

                ExaminationBranchDAO examDAO = new ExaminationBranchDAO();
                return examDAO.InsertStudentMarks(doc.InnerXml);
            }

            catch
            {
                throw;
            }

            finally
            {
                stream.Close();
                stream.Dispose();
            }
        }


public bool InsertStudentMarks(string MarksXML)
        {
            object[] parameters = { MarksXML };

            try
            {
                Int32 n = Convert.ToInt32(db.ExecuteScalar("usp_add_student_marks", parameters));
                if (n > 0)
                {
                    return true;
                }

            }
            catch (System.Data.DataException exception)
            {
                ErrorHandler.WriteError(exception.Message, exception);
            }
            return false;
        }

Followers