Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2007, 03:32 AM
Registered User
 
Join Date: Dec 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default serialization

i first page i wrote the code,here i want to see the serialization



using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    SqlConnection Cn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\Database.mdf;Integrated Security=True;User Instance=True");
    SqlDataAdapter da = new SqlDataAdapter("select * from dept",Cn);
    DataSet ds = new DataSet();



    protected void Page_Load(object sender, EventArgs e)
    {
        ds.Clear();
        da.Fill(ds, "dept");

    }
    protected void Btnsrialize_Click(object sender, EventArgs e)
    {
        ds.WriteXml(MapPath ("~/")+"dept.xml",XmlWriteMode.WriteSchema);
        Response.Write("serialization completed");

    }
}
 and in the second pagfe i took a gridview and wrote this code




using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet ds = new DataSet();
        ds .ReadXml(MapPath("~/")+"dept.xml",XmlReadMode.ReadSchema );
        GridView1.DataBind ();

    }
}


when i'm trying to execute i'm getting this error



Error 1 A field initializer cannot reference the nonstatic field, method, or property '_Default.Cn' d:\taheer\serialization\Default.aspx.cs 15 65 d:\taheer\serialization


plz help me out






Similar Threads
Thread Thread Starter Forum Replies Last Post
A query about serialization vishram123 Java Basics 0 October 1st, 2007 10:06 PM
Serialization and DeSerialization balesh.mind ASP.NET 2.0 Professional 0 September 12th, 2007 05:05 AM
Complex Serialization abedijoo C# 2005 5 April 18th, 2007 10:38 AM
is serialization required for this? hertendreef ASP.NET 2.0 Basics 0 March 24th, 2007 05:54 AM
question about Serialization hertendreef ASP.NET 2.0 Basics 2 February 27th, 2007 04:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.