473,666 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Updating database with changes

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
2 1357
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*******@disc ussions.microso ft.com> wrote in message
news:39******** *************** ***********@mic rosoft.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
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******** *************** ***********@mic rosoft.com
' news:ev******** ******@TK2MSFTN GP10.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*******@disc ussions.microso ft.com> wrote in message
news:39******** *************** ***********@mic rosoft.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2491
by: Paige | last post by:
I have a database on my local machine that I make entries and corrections on. I'd like to be able to upload that to my server and have that update the database that's on the server. What I've been doing is saving the local file as a backup. Then I have to edit the backup, deleting the create file info and all previously uploaded entries before I can import the text file to the server. Is there an easier way to do this so I won't get...
3
2777
by: Robin Tucker | last post by:
Hi there, I have a database on my test machine that will need to be installed on users machines. I would like to create the database with the given schema on the users machine and also with some suitable default values in the tables. I note that although I can script the schema so that re-creating the structure of the database is simple on the users machine, I cannot script the contents of the tables also (automatically). What I would...
3
13050
by: Tc | last post by:
Hi, I was curious, I am thinking of writing an application that loads a dataset from a database that resides on a server. The question I have is this, if multiple copies of the app will be running at once will there be problems with data updates? The reason I ask is I'm thinking like this: User1 launches the app and the dataset is created from the data in the DB.
2
1824
by: Niels Jensen | last post by:
I have a some code which imports information from a text file to a dataset. Depending op what is being extracted from the text file, the dataset has 5 tables which can be written to. During this accessing I have to delete some records depending on certain criteria. I initially had some errors because I wasn't accepting the changes made to the dataset. So using .acceptchanges fixed the issue. however later on in the program a user may...
2
1301
by: Commander Ace | last post by:
Hi, I'm having some problems with updating an SQL Database with modified fields from a datatable. I got the code from a Wrox book, 'Professional VB.NET 2003', the same code can be found here: http://media.wiley.com/product_ancillary/23/07645599/DOWNLOAD/559923_CODE_8_10_16_22_23_24_25.zip \Chapter 16\AuthorEditor Basically when I have made a change and save it, close and reopen the program the changes that I made have gone, and it’s the...
3
8922
by: RSH | last post by:
Hi, I have a situation in where i have two instances of SQL server, the first is our Production Environment, the second is our Development environment. Both servers contain the same databases but I need to write a utility that can transfer a row of data from the Production to the Development servers. I wrote the code below, which doesn't error...but it doesn't work...no data is updated. This is very odd because I can see that both of...
6
2330
by: mike11d11 | last post by:
I'm trying to create an application that will have multiple users working off a table on a SQL server. Since multi users will be updating different records at any given moment, how can i get those changes and merge them into my current Dataset. I've been playing around with the GetChanges method and Acceptchanges but they just dont seem to be pulling over the changes and updating my Dataset. Maybe if someone could give me a sample of...
0
1691
by: OldStd | last post by:
Updating data using 2 data sets I am having some problems in updating the database using two datasets as suggested by someone. 1. Data is displayed in a data grid from a dataset generated using the IDE that pulls data from two tables using an . The idea is to display the associated with the field. Because an is used, the IDE couldn’t auto-generate the Insert command, update command, or Delete command. 2. As a result, it was suggested...
33
3312
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range of 20 steps) On the admin page the steps are listed, in "order" order and the user can create new steps and assign an order and all is well. The problem may come in using a renumber function which should take the steps in their current order...
0
8355
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6191
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4365
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.