Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System;
using System.Data.OleDb;
using System.Data;
using System.Windows;

namespace EAuctionWeb.General
{
public partial class WebForm1 : System.Web.UI.Page
{
OleDbConnection con;
OleDbCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
using (con = new
OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;"+@"Data
Source=C:\Users\INDUJA\Documents\Auction.accdb"))
{
try {
cmd = new OleDbCommand();
cmd.CommandText = "insert into
userdetails(UserName,Education,Location) values('"+txtUsername.Text+ "','" +
txtEducation.Text + "','" + txtLocation.Text + "')";

cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

txtUsername.Text = "";
txtEducation.Text = "";
txtLocation.Text = "";
}
BindUserDetails();
}
protected void BindUserDetails()
{
DataSet ds = new DataSet();
string strquery = "SELECT * FROM userdetails";
using (con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;"
+ @"Data Source=C:\Users\INDUJA\Documents\Auction.accdb"))
{
using (cmd = new OleDbCommand(strquery, con))
{
OleDbDataAdapter Da = new OleDbDataAdapter(cmd);
Da.Fill(ds);
}
}
gvDetails.DataSource = ds;
gvDetails.DataBind();
}
}
}

You might also like