By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,903 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Updating database with changes

P: n/a
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

Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:39**********************************@microsof t.com...
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

Nov 18 '05 #2

P: n/a
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:F4**********************************@microsof t.com
' news:ev**************@TK2MSFTNGP10.phx.gbl

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" <an*******@discussions.microsoft.com> wrote in message
news:39**********************************@microsof t.com...
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

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.