change the existing record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muskan
    New Member
    • Nov 2006
    • 35

    change the existing record

    hello,


    I want to change any of the textbox value and after changing the value when I click on update button record should be reflected into database.

    I don't know how it will be done

    Thanks..
  • sandeepk84
    New Member
    • Oct 2006
    • 97

    #2
    Originally posted by muskan
    hello,


    I want to change any of the textbox value and after changing the value when I click on update button record should be reflected into database.

    I don't know how it will be done

    Thanks..
    Hi Muskan...
    i think u can use d update query to edit the database...
    u have to give d code inside d update button click event...
    for executing update query by code u can have SqlCommand class.
    and executenonquery () method of it.

    eg:
    SqlCommand sqlcmd = new SqlCommand(sqlQ uery, connection variale);
    sqlcmd.ExecuteN onQuery();
    open and close d connection for d operation...
    while writing d sqlQuery. do it with some condition like

    "update table set cols...... where colname=textbox value"

    hope this helps...
    thanx,
    sand..

    Comment

    • muskan
      New Member
      • Nov 2006
      • 35

      #3
      thanks for reply......

      I know this method
      but I want to know some other method for update the records

      I mean to say........
      suppose there 10 textboxes on the form
      and I want to change value of more than 5 textboxes then we have to specify all textboxes value in SET clause .

      I think this is not the good way to update.This method is fine when only 1 or 2 textboxes on the form

      So can u give some other method to update.

      thanks.

      Originally posted by sandeepk84
      Hi Muskan...
      i think u can use d update query to edit the database...
      u have to give d code inside d update button click event...
      for executing update query by code u can have SqlCommand class.
      and executenonquery () method of it.

      eg:
      SqlCommand sqlcmd = new SqlCommand(sqlQ uery, connection variale);
      sqlcmd.ExecuteN onQuery();
      open and close d connection for d operation...
      while writing d sqlQuery. do it with some condition like

      "update table set cols...... where colname=textbox value"

      hope this helps...
      thanx,
      sand..

      Comment

      • sandeepk84
        New Member
        • Oct 2006
        • 97

        #4
        Originally posted by muskan
        thanks for reply......

        I know this method
        but I want to know some other method for update the records

        I mean to say........
        suppose there 10 textboxes on the form
        and I want to change value of more than 5 textboxes then we have to specify all textboxes value in SET clause .

        I think this is not the good way to update.This method is fine when only 1 or 2 textboxes on the form

        So can u give some other method to update.

        thanks.
        Hi Muskan,
        sorry 4 being late...
        did u mean the prob that even if u edit only one txtbox then also u will update the whole cols???
        can u try it using TextBox1_TextCh anged() event?
        means within each textbox's change event u will append the query to d string...
        ie. first u declare a string to store d string - "update table set "
        then within each event append the corresponding textbox value as columns...
        here d prob is that it may not look good if there r many no. of textboxes...
        hope this helps...
        thanx,
        sand...

        Comment

        Working...