Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 12th, 2007, 02: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


 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 03:03 PM



All times are GMT -4. The time now is 03:49 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.