Friday, February 17, 2012

Insert data in access database using ASP.Net

This program will insert data in stud table of Microsoft access database.

Before insert operation:-

After insert Operation:-
 




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;
using System.Data.SqlClient;
using System.Data.Odbc;
using System.Data.OleDb;

public partial class oledb : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {


        OleDbConnection objConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=D:\\mydb.mdb;");

        OleDbCommand objCmd = new OleDbCommand("insert into stud values(200,'aaa','aaa')", objConn);
        OleDbDataReader objReader;
        objConn.Open();
        objReader = objCmd.ExecuteReader();
               
        objConn.Close();

       
    }
}

No comments:

Post a Comment