Saturday, June 28, 2008

creating Xml data in asp.net

protected void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "text/Xml"; 
        int vid = Convert.ToInt32(Request.QueryString["vid"]);
        SqlConnection con = new SqlConnection( ConfigurationManager.
        ConnectionStrings["connect"].ConnectionString);
        SqlDataAdapter cmd = new SqlDataAdapter("select vedioname,vediourl,vediodesc from vedio  where vedioid=@vid", con);
        cmd.SelectCommand.Parameters.Add("@vid", SqlDbType.Int).Value =vid;
        cmd.SelectCommand.CommandType = CommandType.Text;
        DataSet ds = new DataSet();
        cmd.Fill(ds, "root");
        String s = ds.GetXml();
       
        Response.Write(s);
        Response.End();

    }
Share:

0 Comments:

Post a Comment