Click here to Skip to main content
15,893,508 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: table asp Pin
tek 20092-Jun-10 6:01
tek 20092-Jun-10 6:01 
GeneralRe: table asp Pin
Not Active2-Jun-10 7:35
mentorNot Active2-Jun-10 7:35 
AnswerRe: table asp Pin
tek 20092-Jun-10 22:26
tek 20092-Jun-10 22:26 
GeneralRe: table asp [modified] Pin
JHizzle2-Jun-10 23:25
JHizzle2-Jun-10 23:25 
AnswerRe: table asp Pin
Sandeep Mewara2-Jun-10 6:23
mveSandeep Mewara2-Jun-10 6:23 
GeneralRe: table asp Pin
tek 20092-Jun-10 6:42
tek 20092-Jun-10 6:42 
AnswerRe: table asp Pin
Baconbutty3-Jun-10 0:59
Baconbutty3-Jun-10 0:59 
Questiongenerate xml file with sql query Pin
amina892-Jun-10 4:11
amina892-Jun-10 4:11 
Hi,
I work on the code generation xml file I do not know how to modify it to populate the xml using a query sqlserver:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Text;

public partial class Etudiant11 : System.Web.UI.Page
{
    

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public class Etudiant
    {
        public int NumInscription { get; set; }
        public string Nom { get; set; }
        public string Prenom { get; set; }
        public string CodeSexe { get; set; }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        XmlSerializer serializer = new XmlSerializer(typeof(List<Etudiant>));
        List<Etudiant> etudiants = new List<Etudiant>();
       
        FileInfo fi = new FileInfo(@"C:\Temp\Etudiants.xml");

        // Creation d'un étudiant. Peu être créé à partir d'une requête SQL 
        Etudiant etudiant = new Etudiant() { NumInscription = 123, Nom = "xxx", Prenom = "", CodeSexe = "M" };
        // Ajout de l'étudiant à la liste 
        etudiants.Add(etudiant);
        etudiants.Add(etudiant);
        etudiants.Add(etudiant);

        // Création du fichier XML correspondant à la liste d'etudiants 
        using (MemoryStream mem = new MemoryStream())
        {
            serializer.Serialize(mem, etudiants);

            using (FileStream fs = new FileStream(fi.FullName, FileMode.Create))
            {
                using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8))
                {
                    sw.Write(Encoding.UTF8.GetString(mem.ToArray()));
                }
            }
        }

        // Destruction des objets 
        etudiant = null;
        etudiants = null;

        // Lecture du fichier XML généré. 
        // Recréation de la liste d'étudiant 
        using (FileStream stream = fi.OpenRead())
        {
            XmlReader reader = XmlReader.Create(stream);
            string str = reader.ReadInnerXml();

            if (serializer.CanDeserialize(reader))
            {
                etudiants = (List<Etudiant>)serializer.Deserialize(reader);
            }
        }

        // Pour chaque étudiant de la liste on reconstitue des requêtes SQL de mise à jour. 
        foreach (Etudiant ee in etudiants)
        {
           Response .Write  (string.Format("UPDATE ETUDIANT SET ETUDIANT_NOM = '{0}', ETUDIANT_PRENOM = '{1}', CODE SEXE = '{2}' WHERE NUM_INSCRIPTION = {3}", ee.Nom, ee.Prenom, ee.CodeSexe, ee.NumInscription));
        }

        
    }
}
thanks
QuestionRe: generate xml file with sql query Pin
Rhys Jacob2-Jun-10 4:21
Rhys Jacob2-Jun-10 4:21 
AnswerRe: generate xml file with sql query Pin
dan!sh 2-Jun-10 4:43
professional dan!sh 2-Jun-10 4:43 
GeneralRe: generate xml file with sql query Pin
amina892-Jun-10 10:49
amina892-Jun-10 10:49 
GeneralRe: generate xml file with sql query Pin
dan!sh 2-Jun-10 16:53
professional dan!sh 2-Jun-10 16:53 
QuestionRe: generate xml file with sql query Pin
amina892-Jun-10 20:04
amina892-Jun-10 20:04 
Questionhow to print iframe contents without opening print dialog [modified] Pin
raghvendrapanda2-Jun-10 1:44
raghvendrapanda2-Jun-10 1:44 
AnswerRe: how to print iframe contents without opening print dialog Pin
JHizzle2-Jun-10 2:34
JHizzle2-Jun-10 2:34 
GeneralRe: how to print iframe contents without opening print dialog Pin
raghvendrapanda2-Jun-10 2:57
raghvendrapanda2-Jun-10 2:57 
GeneralRe: how to print iframe contents without opening print dialog Pin
JHizzle3-Jun-10 3:11
JHizzle3-Jun-10 3:11 
QuestionHow to Develop Hosting Website using Asp.net Pin
Member 47201842-Jun-10 0:42
Member 47201842-Jun-10 0:42 
AnswerRe: How to Develop Hosting Website using Asp.net Pin
Peace ON2-Jun-10 2:36
Peace ON2-Jun-10 2:36 
GeneralRe: How to Develop Hosting Website using Asp.net Pin
Jason Vetter3-Jun-10 11:11
Jason Vetter3-Jun-10 11:11 
Questionretrive client logical drives in alternative of Directory.GetLogicalDrive which used in server side Pin
Punit Belani1-Jun-10 23:45
Punit Belani1-Jun-10 23:45 
AnswerRe: retrive client logical drives in alternative of Directory.GetLogicalDrive which used in server side Pin
Sandeep Mewara2-Jun-10 0:00
mveSandeep Mewara2-Jun-10 0:00 
GeneralRe: retrive client logical drives in alternative of Directory.GetLogicalDrive which used in server side Pin
Punit Belani2-Jun-10 0:09
Punit Belani2-Jun-10 0:09 
AnswerRe: retrive client logical drives in alternative of Directory.GetLogicalDrive which used in server side Pin
walterhevedeich2-Jun-10 0:11
professionalwalterhevedeich2-Jun-10 0:11 
GeneralRe: retrive client logical drives in alternative of Directory.GetLogicalDrive which used in server side Pin
Punit Belani2-Jun-10 0:19
Punit Belani2-Jun-10 0:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.