Israel

Israel

  • NA
  • 1.3k
  • 203k

Need to update specific row from a specific date

Mar 23 2015 11:28 AM

Hi!

I have a table with many columns. But I wrote these codes to update ONLY the exact date for a specific column ‘anex’ row. But curiosly its update the all columns ‘date’, name and anex with the same date he found on the maskeedit. After to make my filter I need him to update ONLY the ‘anex’ column row (not the all column).

private void test_Click(object sender, EventArgs e)

{

{

conn = new OleDbConnection(connstr);

comm = new OleDbCommand();

conn.Open();

OleDbParameter date = new OleDbParameter("@date", SqlDbType.VarChar);

OleDbParameter name = new OleDbParameter("@name", SqlDbType.VarChar);

       OleDbParameter anex = new OleDbParameter("@anex", SqlDbType.VarChar);

   comm.Parameters.Add(date);

   comm.Parameters.Add(name);

   comm.Parameters.Add(anex);

   date.Value = date.Text;

   name.Value = name.Text;

   anex.Value = anex.Text;

comm.Connection = conn;

comm.CommandText = "UPDATE test SET date = @date, name = @name, anex = @anex WHERE ([date] = @date)";

try

{

comm.ExecuteNonQuery();

MessageBox.Show("Updated");

}

catch (Exception)

{

MessageBox.Show("Not Updated");

}

finally

{

conn.Close();


Answers (3)