Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button6_Click(object sender, EventArgs e)
- {
- try
- {
- connection.Open();
- OleDbCommand command = new OleDbCommand();
- command.Connection = connection;
- string query =
- "UPDATE Marc SET Marcstud =@ln Where IDSubject=@subject AND IDStudent=@student";
- //command.Parameters.AddWithValue("@ln", Convert.ToInt32(textBox_m.Text));
- //command.Parameters.AddWithValue("@student", Convert.ToInt32(textBox_S.Text));
- //command.Parameters.AddWithValue("@subject", Convert.ToInt32(textBox_p.Text));
- command.Parameters.AddWithValue("@ln", 4);
- command.Parameters.AddWithValue("@student", 301);
- command.Parameters.AddWithValue("@subject", 101);
- MessageBox.Show(query);
- command.CommandText = query;
- command.ExecuteNonQuery();
- MessageBox.Show("data edit successful");
- connection.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show("error" + ex); ;
- }
- }
- public void Update(String connectionString)
- {
- var ln = Convert.ToInt32(textBox_m.Text);
- var student = Convert.ToInt32(textBox_S.Text);
- var subject = Convert.ToInt32(textBox_p.Text);
- using (var connection = new OleDbConnection(connectionString))
- {
- using (var command = connection.CreateCommand())
- {
- command.CommandText = "UPDATE Marc SET Marcstud = @ln Where IDSubject = @subject AND IDStudent = @student;";
- command.Parameters.AddRange(new OleDbParameter[]
- {
- new OleDbParameter("@ln", ln),
- new OleDbParameter("@student", student),
- new OleDbParameter("@subject", subject)
- });
- connection.Open();
- command.ExecuteNonQuery();
- }
- }
- }
Add Comment
Please, Sign In to add comment