ClonecMr cool

ClonecMr cool

  • NA
  • 34
  • 18.6k

cmd.executeNonQuery ??

Jun 10 2011 11:09 PM
Hello,
can some body tell me,

what the best methode to delete row without dataset and data table ?
and than the result of deleted row can show into text box.

---snip---

 
 private void btnptong_Click(object sender, EventArgs e)
  {
  if (MessageBox.Show("Ente Yakin Gan ?", "Konfirmasi Hapus Data", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes )
  {
 
  // proceed with deletion

  NpgsqlConnection conn = new NpgsqlConnection(connstr);
  NpgsqlCommand cmds = conn.CreateCommand();
  cmds.CommandText =
 
  "DELETE FROM smsinbox WHERE timereceived < '" + dateTimePicker1.Text + "';" +
  "DELETE FROM smsoutbox WHERE timesent < '" + dateTimePicker1.Text + "';" +
  "DELETE FROM customer WHERE transactiontime < '" + dateTimePicker1.Text + "';";

  conn.Open();

  if (conn.State == ConnectionState.Open)
  {
 
  cmds.ExecuteNonQuery();
 
  }
  else
  {
  MessageBox.Show("Error");
  }

  conn.Close();
  }
  }


--- end snip ----

It's working, with no information result.
No message like "Query returned successfully: 100 rows affected, 302 ms execution time."  to shown.
So I'm not know the job has been finished or not.

I'm Not Sure it's true way ...

any suggestion will be appreciated :)


Answers (5)