本文介绍了我需要这个问题的快速答案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是编程新手..我试图为我的办公室创建计费系统..我正在使用访问数据库.我想知道如何添加,更新,删除数据.请使用代码或类似的示例帮助我.
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 .
推荐答案
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();
这篇关于我需要这个问题的快速答案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!