Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- OleDbConnection con = new
- OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\database_for_kissan_Pashu_AhaR_Bills.mdb");
- int balance = Convert.ToInt32(textBox2.Text);
- int id = Convert.ToInt32(textBox1.Text);
- // int recordnumb = int.Parse(recordTextBox.Text);
- // OleDbConnection oleDbConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Checkout-1\Documents\contact.accdb");
- OleDbCommand update = new OleDbCommand("UPDATE Customers SET Balance = '" + balance + "', WHERE id = " + id + " ", con);
- con.Open();
- update.ExecuteNonQuery();
- con.Close();
- // string queryText = "UPDATE Customers SET Balance = ?, where CustomerId = ?;";
- //string queryText = " 'UPDATE Customers SET Balance =' " + balance+ " ' WHERE CustomerId= ' " + id + " ' " ;
- //OleDbCommand cmd = new OleDbCommand(queryText, con);
- //cmd.CommandType = CommandType.Text;
- //cmd.Parameters.AddWithValue("@balance", Convert.ToInt32(textBox2.Text));
- //cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(textBox1.Text));
- //cmd.Parameters.Add("Balance", OleDbType.Integer).Value = Convert.ToInt32(textBox2.Text);
- //cmd.Parameters.Add("CustomerId", OleDbType.Integer).Value = Convert.ToInt32(textBox1.Text);
- //con.Open(); // open the connection
- ////OleDbDataReader dr = cmd.ExecuteNonQuery();
- //int yy = cmd.ExecuteNonQuery();
- //con.Close();
- }
- catch (Exception ex)
- {
- string c = ex.ToString();
- MessageBox.Show(c);
- }
- //try
- //{
- // 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");
- // string queryText = "UPDATE Customers SET Balance = ?, where CustomerId = ?;";
- // OleDbCommand cmd = new OleDbCommand(queryText, con);
- // cmd.CommandType = CommandType.Text;
- // //cmd.Parameters.AddWithValue("@balance", Convert.ToInt32(textBox2.Text));
- // //cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(textBox1.Text));
- // cmd.Parameters.Add("Balance", OleDbType.Integer).Value = Convert.ToInt32(textBox2.Text);
- // cmd.Parameters.Add("CustomerId", OleDbType.Integer).Value = Convert.ToInt32(textBox1.Text);
- // con.Open(); // open the connection
- // //OleDbDataReader dr = cmd.ExecuteNonQuery();
- // int yy = cmd.ExecuteNonQuery();
- // con.Close();
- //}
- //catch (Exception ex)
- //{
- // string c = ex.ToString();
- // MessageBox.Show(c);
- //}
- //string connetionString = null;
- //OleDbConnection connection;
- //OleDbDataAdapter oledbAdapter = new OleDbDataAdapter();
- //string sql = null;
- //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;";
- //connection = new OleDbConnection(connetionString);
- //sql = "update Customers set Balance = '1807' where CustomerId = '1'";
- //try
- //{
- // connection.Open();
- // oledbAdapter.UpdateCommand = connection.CreateCommand();
- // oledbAdapter.UpdateCommand.CommandText = sql;
- // oledbAdapter.UpdateCommand.ExecuteNonQuery();
- // MessageBox.Show("Row(s) Updated !! ");
- // connection.Close();
- //}
- //catch (Exception ex)
- //{
- // MessageBox.Show(ex.ToString());
- //}
- string queryText = "UPDATE Customers SET Balance = ?, where CustomerId = ?;";
- string queryText = "UPDATE Customers SET Balance = ? where CustomerId = ?;";
- "UPDATE Customers SET Balance = " + balance + " WHERE id = " + id
- OleDbCommand update = new OleDbCommand("UPDATE Customers SET Balance = '" + balance + "' WHERE id = " + id + " ", con);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement