none
data update problem RRS feed

  • Question

  • M having problem in update query string its a syntax error plz help me out ! m using Update method on dataAdapter

    m_daDataAdapter=

    new OleDbDataAdapter("UPDATE Appointments SET Appointment Date/Time " + " where Appointment Date/Time = textBox28.Text",m_cnADONetConnection);

    Appointments is a dataTable n appointment date/time is its column

    Saturday, June 12, 2010 12:14 PM

Answers

  • Your query is invalid.

    Please try below

    "UPDATE Appointments SET Appointment DateTime =" + newDateTime +  " where Appointment Date/Time = " + textBox28.Text

    But why are you using DataAdapter for Update Statement.

    You can use below code for update

    SqlCommand cmd=m_CaDonetConnection.CreateCommand();

    cmd.CommandText="Update Appontment Set Appointment=@newAppointment WHERE AppointmentDateTime=@OldAppointment";

    cmd.Parameters.AddWithValue("newAppointment",txtNewAppointDateTime.txt)

    cmd.Parameters.AddWithValue("OldAppointment",txtOldAppointDateTime.txt)

    cmd.ExecuteNonQuery();
     


    Regards
    Nayan Paregi (MCTS)
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by nur2010 Saturday, June 12, 2010 1:45 PM
    • Unmarked as answer by nur2010 Saturday, June 12, 2010 2:24 PM
    • Marked as answer by nur2010 Sunday, June 13, 2010 2:50 PM
    Saturday, June 12, 2010 12:46 PM