Updating database with changes

Discussion in 'ASP .Net' started by =?Utf-8?B?R2VpciBTYW5uZQ==?=, May 5, 2004.

  1. hi!!

    how am i supposed to update the db witht he changes the user make in webpage

    am trying to make a simple page that have a grid bound to a table

    the user can delete,add or update the grid

    how do i get the changes into the database

    after the page is loaded the dataset is gone so the databinding only works for reading

    do i really have to make an array and handle the updating myself

    regard
    geir sann
     
    =?Utf-8?B?R2VpciBTYW5uZQ==?=, May 5, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?R2VpciBTYW5uZQ==?=

    Rick Spiewak Guest

    If you want to do updates, you should use a dataset. It sounds like you may
    be using a datareader - if so, switch to a dataset.
    To update using a dataset, make changes to the datatable during the update
    event on the datagrid. Then, use the GetChanges method on the datatable to
    construct a new table with the changes. Call the appropriate update method
    for each changed row - insert, update, or delete.

    "Geir Sanne" <> wrote in message
    news:...
    > hi!!!
    >
    > how am i supposed to update the db witht he changes the user make in

    webpage ?
    >
    > am trying to make a simple page that have a grid bound to a table.
    >
    > the user can delete,add or update the grid.
    >
    > how do i get the changes into the database ?
    >
    > after the page is loaded the dataset is gone so the databinding only works

    for reading ?
    >
    > do i really have to make an array and handle the updating myself ?
    >
    > regards
    > geir sanne
    >
     
    Rick Spiewak, May 5, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?R2VpciBTYW5uZQ==?=

    Alec MacLean Guest

    Geir,

    There are loads of examples on various specialist websites: www.123aspx.com
    is a good place to bookmark.
    I can tell you from my own experience I didn't want to use the default
    asp.net methods of working with the datagrid, so I rolled my own after
    learning from Microsoft and other examples.

    Basically, I use stored procedures for all db read/write operations and do
    all grid databinding in custom (VB) procedures.

    So a page's code-behind might look something like:

    Sub page_load (...) Handles ...
    if Not page.ispostback then
    'If required, ensure user is authenticated/authorised

    'Get default data for display...
    me.BindMyGrid()

    end if

    end sub


    private sub BindMyGrid()
    'Do the bind routine...
    'Set up a connection to db and retrieve required data
    'See my response posting for Tracey for example connection method:
    'Re: Urgent: I can't update database with SqlCommand
    ' news:
    ' news:

    end sub

    private sub cmdSaveData(....) Handles ...
    'Respond to the command button being clicked
    'Validate all input
    'I use try-catch statements for validation...
    'Again, see the above message thread for my example technique for
    validation and attaching values to send to the sproc/db
    '
    end sub

    HTH
    --
    Alec MacLean


    "Geir Sanne" <> wrote in message
    news:...
    > hi!!!
    >
    > how am i supposed to update the db witht he changes the user make in

    webpage ?
    >
    > am trying to make a simple page that have a grid bound to a table.
    >
    > the user can delete,add or update the grid.
    >
    > how do i get the changes into the database ?
    >
    > after the page is loaded the dataset is gone so the databinding only works

    for reading ?
    >
    > do i really have to make an array and handle the updating myself ?
    >
    > regards
    > geir sanne
    >
     
    Alec MacLean, May 5, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luis Esteban Valencia
    Replies:
    1
    Views:
    1,419
    Carl Prothman [MVP]
    Jan 12, 2005
  2. Jeff
    Replies:
    1
    Views:
    386
  3. teclioness

    GridView not updating changes

    teclioness, Apr 18, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    9,686
    teclioness
    Apr 19, 2006
  4. Mark Olbert

    Updating Design Time When Property Changes

    Mark Olbert, Jan 31, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    646
    Walter Wang [MSFT]
    Jan 31, 2007
  5. news.rcn.com
    Replies:
    2
    Views:
    1,161
    Roedy Green
    Dec 10, 2007
Loading...

Share This Page