You are on page 1of 2

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.OleDb;

public partial class _Default : System.Web.UI.Page


{
OleDbConnection con;
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:/db1.mdb");
con.Open();
}
protected void Button2_Click(object sender, EventArgs e)
{
OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:/db1.mdb");
con.Open();
OleDbCommand cmd = new OleDbCommand("Insert into Table1
values(@pasid,@name,@age,@arrival,@departure,@passportno)", con);
cmd.Parameters.AddWithValue("@pasid", txtpasid.Text);
cmd.Parameters.AddWithValue("@name", txtname.Text);
cmd.Parameters.AddWithValue("@age", txtage.Text);
cmd.Parameters.AddWithValue("@arrival", txtarrival.Text);
cmd.Parameters.AddWithValue("@departure", txtdeparture.Text);
cmd.Parameters.AddWithValue("@passportno", txtpassportno.Text);
cmd.ExecuteNonQuery();
}
protected void btndelete_Click(object sender, EventArgs e)
{
OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:/db1.mdb");
con.Open();
OleDbCommand cmd = new OleDbCommand("Delete from Table1 where
pasid=@pasid", con);
cmd.Parameters.AddWithValue("@pasid", txtpasid.Text);
cmd.ExecuteNonQuery();
}
protected void btnupdate_Click(object sender, EventArgs e)
{
OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:/db1.mdb");
con.Open();
OleDbCommand cmd = new OleDbCommand("update Table1 set
pasid=@pasid,name=@name,age=@age,arrival=@arrival,departure=@departure,p
assportno=@passportno where pasid=@pasid", con);
cmd.Parameters.AddWithValue("@pasid", txtpasid.Text);
cmd.Parameters.AddWithValue("@name", txtname.Text);
cmd.Parameters.AddWithValue("@age", txtage.Text);
cmd.Parameters.AddWithValue("@arrival", txtarrival.Text);
cmd.Parameters.AddWithValue("@departure", txtdeparture.Text);
cmd.Parameters.AddWithValue("@passportno", txtpassportno.Text);
cmd.ExecuteNonQuery();
}
protected void btnclear_Click(object sender, EventArgs e)
{

txtpasid.Text = "";
txtname.Text = "";
txtage.Text = "";
txtarrival.Text = "";
txtdeparture.Text = "";
txtpassportno.Text = "";
txtpasid.Focus();
}
}

You might also like