Advertisement
Guest User

Untitled

a guest
Aug 5th, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. try
  2. {
  3. OleDbConnection con = new
  4. OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\database_for_kissan_Pashu_AhaR_Bills.mdb");
  5.  
  6. int balance = Convert.ToInt32(textBox2.Text);
  7. int id = Convert.ToInt32(textBox1.Text);
  8.  
  9. // int recordnumb = int.Parse(recordTextBox.Text);
  10.  
  11. // OleDbConnection oleDbConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Checkout-1\Documents\contact.accdb");
  12. OleDbCommand update = new OleDbCommand("UPDATE Customers SET Balance = '" + balance + "', WHERE id = " + id + " ", con);
  13.  
  14. con.Open();
  15. update.ExecuteNonQuery();
  16. con.Close();
  17.  
  18. // string queryText = "UPDATE Customers SET Balance = ?, where CustomerId = ?;";
  19. //string queryText = " 'UPDATE Customers SET Balance =' " + balance+ " ' WHERE CustomerId= ' " + id + " ' " ;
  20.  
  21. //OleDbCommand cmd = new OleDbCommand(queryText, con);
  22. //cmd.CommandType = CommandType.Text;
  23. //cmd.Parameters.AddWithValue("@balance", Convert.ToInt32(textBox2.Text));
  24. //cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(textBox1.Text));
  25. //cmd.Parameters.Add("Balance", OleDbType.Integer).Value = Convert.ToInt32(textBox2.Text);
  26. //cmd.Parameters.Add("CustomerId", OleDbType.Integer).Value = Convert.ToInt32(textBox1.Text);
  27.  
  28. //con.Open(); // open the connection
  29. ////OleDbDataReader dr = cmd.ExecuteNonQuery();
  30.  
  31. //int yy = cmd.ExecuteNonQuery();
  32. //con.Close();
  33. }
  34. catch (Exception ex)
  35. {
  36. string c = ex.ToString();
  37. MessageBox.Show(c);
  38. }
  39.  
  40. //try
  41. //{
  42. // OleDbConnection con = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = G:\my Documents\Visual Studio 2008\Projects\xml_and_db_test\xml_and_db_test\bin\Debug\database_for_kissan_Pashu_AhaR_Bills.mdb");
  43. // string queryText = "UPDATE Customers SET Balance = ?, where CustomerId = ?;";
  44.  
  45. // OleDbCommand cmd = new OleDbCommand(queryText, con);
  46. // cmd.CommandType = CommandType.Text;
  47. // //cmd.Parameters.AddWithValue("@balance", Convert.ToInt32(textBox2.Text));
  48. // //cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(textBox1.Text));
  49.  
  50. // cmd.Parameters.Add("Balance", OleDbType.Integer).Value = Convert.ToInt32(textBox2.Text);
  51.  
  52. // cmd.Parameters.Add("CustomerId", OleDbType.Integer).Value = Convert.ToInt32(textBox1.Text);
  53. // con.Open(); // open the connection
  54. // //OleDbDataReader dr = cmd.ExecuteNonQuery();
  55.  
  56. // int yy = cmd.ExecuteNonQuery();
  57. // con.Close();
  58.  
  59. //}
  60. //catch (Exception ex)
  61. //{
  62. // string c = ex.ToString();
  63. // MessageBox.Show(c);
  64.  
  65. //}
  66. //string connetionString = null;
  67. //OleDbConnection connection;
  68. //OleDbDataAdapter oledbAdapter = new OleDbDataAdapter();
  69. //string sql = null;
  70. //connetionString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = G:\my Documents\Visual Studio 2008\Projects\xml_and_db_test\xml_and_db_test\bin\Debug\database_for_kissan_Pashu_AhaR_Bills.mdb;";
  71. //connection = new OleDbConnection(connetionString);
  72. //sql = "update Customers set Balance = '1807' where CustomerId = '1'";
  73. //try
  74. //{
  75. // connection.Open();
  76. // oledbAdapter.UpdateCommand = connection.CreateCommand();
  77. // oledbAdapter.UpdateCommand.CommandText = sql;
  78. // oledbAdapter.UpdateCommand.ExecuteNonQuery();
  79. // MessageBox.Show("Row(s) Updated !! ");
  80. // connection.Close();
  81. //}
  82. //catch (Exception ex)
  83. //{
  84. // MessageBox.Show(ex.ToString());
  85. //}
  86.  
  87. string queryText = "UPDATE Customers SET Balance = ?, where CustomerId = ?;";
  88.  
  89. string queryText = "UPDATE Customers SET Balance = ? where CustomerId = ?;";
  90.  
  91. "UPDATE Customers SET Balance = " + balance + " WHERE id = " + id
  92.  
  93. OleDbCommand update = new OleDbCommand("UPDATE Customers SET Balance = '" + balance + "' WHERE id = " + id + " ", con);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement