Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
i am new to programming.. I trying to create billing system for my office.. I am using access database. i want to know how to add,update,delete data. pls help me with a code or any example which is similar .
Posted

Here is an example

OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(Application.ExecutablePath) + "\\NBS.mdb;");
        OleDbCommand cmd;


string strSQL1 = ("insert into DailyTrans_Master (ReceiptNo,ReceiptDate,Cust_ID,Amt_paid,ForMonth,ForYear)");
                        strSQL1 += ("values ('" + txtReceiptNo.Text + "',Date()," + txtCustomerID.Text + "," + txtAmt.Text + ",'" + cmbMonth.Text + "','" + cmbYear.Text + "')");
                        con.Open();
                        cmd = new OleDbCommand(strSQL1, con);
                        cmd.ExecuteNonQuery();
                        con.Close();

string strSQL = "update Receipt_Master_" + cmbYear.Text + " set [Jan]= " + txtAmt.Text + " where [Cust_ID]= " + txtCustomerID.Text + "";
                        con.Open();
                        cmd = new OleDbCommand(strSQL, con);
                        cmd.ExecuteNonQuery();
                        con.Close();

string SQL = "delete from area_master where area_Name = '" + txtAreaName.Text + "' and area_Code = '" + txtAreaCode.Text + "'";
                con.Open();
                cmd = new OleDbCommand(SQL, con);
                cmd.ExecuteNonQuery();
                con.Close();
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900