Программирование в IIS




Пример 2.11


using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.OleDb; //for the OleDb classes

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

namespace SimpleWF

{

///

/// Summary description for datalist.

///

public class datalist : System.Web.UI.Page

{

protected System.Web.UI.WebControls.DataList dlChair;

private void LoadList(DataList dl)

{

//set the connection credentials

string DataSetName = "myChairs";

string ConnectionString =

"Provider=Microsoft.Jet.OLEDB.4.0;" +

"Data Source=C:\\aspData\\employees.mdb;";

//make the DB connection

OleDbConnection myConn = new

OleDbConnection(ConnectionString);

//make a data set to hold chairs

DataSet myDataSet = new DataSet(DataSetName);

//make a data adaptor

OleDbDataAdapter myAdapt = new

OleDbDataAdapter("Select * From tblChair", myConn);

//fill the dataset

myAdapt.Fill(myDataSet);

//show the data in the data list

dl.DataSource = myDataSet;

dl.DataBind();

}

private void Page_Load(object sender, System.EventArgs e)

{

LoadList(this.dlChair);

}

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the

// ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}

///

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

///

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}

}




Содержание  Назад  Вперед