using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Example
{
	/// <summary>
	/// AccessExceptionExample 的摘要说明。
	/// </summary>
	public class AccessExceptionExample : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			string ConnStr = @"Provider=Microsoft.Jet.OLEDB.4.0; Data source=D:\网站项目\baddot.net\wangwen\DB\baddot2000.mdb;";
			//string query = "DELETE FROM wenzhang WHERE id=225";
			//string query = "INSERT INTO wenzhang (author) VALUES ('aaaa')";
			string query = "UPDATE wenzhang SET subject = '新标题' WHERE id=224 ";
			//Response.Write(query);

			System.Data.OleDb.OleDbConnection oleDbConnection = new System.Data.OleDb.OleDbConnection(ConnStr);
			System.Data.OleDb.OleDbCommand oleDbCommand = new System.Data.OleDb.OleDbCommand(query, oleDbConnection);

			try
			{
				oleDbCommand.Connection.Open();
				oleDbCommand.ExecuteNonQuery();
			}
			catch(Exception ex)
			{
				Label1.Text = ex.Message;
			}
			finally
			{
				oleDbCommand.Connection.Close();
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}
