KayD
Member • Mar 9, 2010
.net coding
Hey all, i have a slight problem with my code.
I have a database in access called Suppliers, which has two tables-Suplier_Master and Supplier_Accounts, in which i want to perform an insertion operation. The problem is that though the system does not show any errors, there is no insertion happening in the database table either. I have practically given up trying to solve this problem. Any help would be appreciated.
the code is as follows:
string cnstr1 = ConfigurationManager.ConnectionStrings["WindowsFormsApplication3.Properties.Settings.SupplierConnectionString"].ConnectionString;
OleDbConnection sup=new OleDbConnection();
sup.ConnectionString=cnstr1;
sup.Open();
string updates = string.Format("Insert into Supplier_Accounts" + "(Supplier_Name,S_Amt_Payable,S_Amt_Paid,S_Due_Date,Order_Date,Item,Rate,Quantity)" +
"Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')",supplier, AmountDue, AmountPaid, DueDate, today, desc, rate, Quantity);
using (OleDbCommand cmds = new OleDbCommand(updates, sup))
{
cmds.ExecuteNonQuery();
}
string s = string.Format("Update Suplier_Master Set S_Amt_Pending='{0}' where Supplier_Name='{1}'", AmtPending, supplier);
using (OleDbCommand cmdsp = new OleDbCommand(s, sup))
{
cmdsp.ExecuteNonQuery();
}
I have a database in access called Suppliers, which has two tables-Suplier_Master and Supplier_Accounts, in which i want to perform an insertion operation. The problem is that though the system does not show any errors, there is no insertion happening in the database table either. I have practically given up trying to solve this problem. Any help would be appreciated.
the code is as follows:
string cnstr1 = ConfigurationManager.ConnectionStrings["WindowsFormsApplication3.Properties.Settings.SupplierConnectionString"].ConnectionString;
OleDbConnection sup=new OleDbConnection();
sup.ConnectionString=cnstr1;
sup.Open();
string updates = string.Format("Insert into Supplier_Accounts" + "(Supplier_Name,S_Amt_Payable,S_Amt_Paid,S_Due_Date,Order_Date,Item,Rate,Quantity)" +
"Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')",supplier, AmountDue, AmountPaid, DueDate, today, desc, rate, Quantity);
using (OleDbCommand cmds = new OleDbCommand(updates, sup))
{
cmds.ExecuteNonQuery();
}
string s = string.Format("Update Suplier_Master Set S_Amt_Pending='{0}' where Supplier_Name='{1}'", AmtPending, supplier);
using (OleDbCommand cmdsp = new OleDbCommand(s, sup))
{
cmdsp.ExecuteNonQuery();
}