You must Sign In to post a response.
  • Category: .NET

    I need insert,update,delete,search,queries in oledb method

    I need insert,update,delete,search,queries in oledb method,
    anyone post me
  • #749950
    Hi Jiyaulhuk, Could you please tell us what is the requirement clearly so that we can provide our best. are you trying to import and edit and reading excel files using OLEDB? then go thorugh the below links.
    http://csharp.net-informations.com/excel/csharp-excel-oledb-insert.htm
    http://csharp.net-informations.com/excel/csharp-excel-oledb.htm
    http://csharp.net-informations.com/excel/csharp-excel-oledb-update.htm
    Else say the clear requirement to us. Thanks for reading.

    Rajesh B
    To Live More,Learn More

  • #749965
    Hai Jiyaulhuk,
    There is no difference between the SQL, Oracle or OleDb.These are the separate layers through which you can connect with the database.
    So if you know how to connect with the SQL or Oracle, you can use the same procedure for OleDb.
    You just need to replace the SqlConnection to OleDbConnection and similar for other database objects.
    Below is a sample for the Insert statement:

    using System.Data.OleDb;

    try
    {
    OleDbConnection con ;
    OleDbCommand cmd = new OleDbCommand();
    string sql = null;
    con = new OleDbConnection("<provide connection string>");
    con.Open();
    cmd.Connection = con;
    sql = "INSERT <TABLENAME> VALUES('AAA','BBB')";
    cmd.CommandText = sql;
    cmd.ExecuteNonQuery();
    con.Close();
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.ToString());
    }

    You can use the similar queries for your other CRUD operations.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #749978
    hi
    Refer this url
    http://www.c-sharpcorner.com/uploadfile/e628d9/creating-retrieving-records-from-m-s-access-2007-using-oledb-in-C-Sharp-net/
    http://www.c-sharpcorner.com/uploadfile/e628d9/inserting-images-into-ms-access-file-using-oledb/

    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #750004
    Hi use the below code...

    //Search Data from table:

    OleDbConnection conn = new OleDbConnection();
    OleDbCommand cmd = new OleDbCommand();
    OleDbDataAdapter adp = new OleDbDataAdapter();
    DataSet ds = new DataSet();
    DataTable dt = new DataTable();

    private void AdmissionFees_Load(object sender, EventArgs e)
    {
    OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["myconnection"].ToString());

    if (conn.State == ConnectionState.Closed)
    {
    conn.Open();
    }

    adp = new OleDbDataAdapter("select * from CurrentFees_month where std_name = '" + txtstdname.Text + "' and descp ='Paid' ", conn);

    ds = new DataSet();

    adp.Fill(ds);

    dataGridView1.DataSource = ds.Tables[0];

    // Update command


    if (conn.State == ConnectionState.Closed)
    {
    conn.Open();
    }

    try
    {
    //cmd = new OleDbCommand("Insert into Admission_Fees values ('" + txtadmissionno.Text.Trim() + "','" + txtstdname.Text.Trim() + "', '" + cmbclass.SelectedItem.ToString() + "', '" + cmbsec.SelectedItem.ToString() + "', '" + txtbillno.Text.Trim() + "' ,'" + txtbilldate.Text.Trim() + "', '" + txtadmissionfees.Text.Trim() + "', '" + txtfeespaid.Text.Trim() + "','" + cmbvanfees.SelectedItem.ToString() + "', '" + txtdisc.Text.Trim() + "') ", conn);

    cmd = new OleDbCommand(" Update Admission_Fees Set Admiss_No = '" + txtadmissionno.Text.Trim() + "',Std_Name = '" + txtstdname.Text.Trim() + "', Std_Class = '" + cmbclass.SelectedItem.ToString() + "', Std_Sec = '" + cmbsec.SelectedItem.ToString() + "', Bill_No = '" + txtbillno.Text.Trim() + "' , Bill_Date = '" + txtbilldate.Text.Trim() + "', Add_Fees = '" + txtadmissionfees.Text.Trim() + "',Van_Fees = '" + cmbvanfees.SelectedItem.ToString() + "', Description = '" + txtdisc.Text.Trim() + "' where Admiss_No = '" + txtadmissionno.Text.Trim() + "' ", conn);

    int n = cmd.ExecuteNonQuery();

    if (n > 0)
    {
    MessageBox.Show("Admission Fees Paid Successful", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Information);

    cmbclasssearch.Focus();

    }
    }
    catch (Exception x)
    {
    MessageBox.Show(x.Message);
    }

    finally
    {
    conn.Close();

    }

    //Insert command


    cmd = new OleDbCommand("Insert into std_upgrade values ('" + txtadmissionno.Text.Trim() + "', '" + txtstdname.Text.Trim() + "', '" + cmbclass.SelectedItem.ToString() + "', '" + cmbsection.SelectedItem.ToString() + "')", conn);

    cmd.ExecuteNonQuery();

    //Delete Command

    -----------------------------------------------------------------------------
    Regards,
    Gopi A.
    +91 9894315571
    Skype:gopi.net
    http://asaigopi-dotnet.blogspot.in/


  • Sign In to post your comments