473,657 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to update the database when data on a datagrid has changed?

Hi, I have a datagrid and its source is a dataset. When I change information
on the grid does that automatically gets change in the dataset? If not then
how do I do that? I use the following update statement when the form is
closed to udpate the database but the changes are not there.
oleDbDataAdapte r1.Update(dsVeh icle, "vehDetail" );

Thanks, Alpha
Nov 17 '05 #1
3 2685
Hi,
You could try

dsVehicle.Table s[ "vehDetail" ].RowChanged +=
new DataRowChangeEv entHandler(data Row_Change);
..
..
..
private void DataRow_Change( object sender, DataRowChangeEv entArgs e)
{
oleDbDataAdapte r1.Update(dsVeh icle, "vehDetail" );
}

All the best,
Phil.

"Alpha" wrote:
Hi, I have a datagrid and its source is a dataset. When I change information
on the grid does that automatically gets change in the dataset? If not then
how do I do that? I use the following update statement when the form is
closed to udpate the database but the changes are not there.
oleDbDataAdapte r1.Update(dsVeh icle, "vehDetail" );

Thanks, Alpha

Nov 17 '05 #2
I definitely see action with the code you gave me. Thank you very much.

However, I'm getting update error. One of the column in the dataset is a
primary key in the database. The update command is automatically generated
when I add the dbapater control to the form. It tries to update the primary
key columnas well.
Can you suggest how I can fix this problem? Thanks.

I'm gonna try to set that column in dataset to a primary key and see if that
would help.

"Phil Williams" wrote:
Hi,
You could try

dsVehicle.Table s[ "vehDetail" ].RowChanged +=
new DataRowChangeEv entHandler(data Row_Change);
.
.
.
private void DataRow_Change( object sender, DataRowChangeEv entArgs e)
{
oleDbDataAdapte r1.Update(dsVeh icle, "vehDetail" );
}

All the best,
Phil.

"Alpha" wrote:
Hi, I have a datagrid and its source is a dataset. When I change information
on the grid does that automatically gets change in the dataset? If not then
how do I do that? I use the following update statement when the form is
closed to udpate the database but the changes are not there.
oleDbDataAdapte r1.Update(dsVeh icle, "vehDetail" );

Thanks, Alpha

Nov 17 '05 #3
I just open the dataset schema and it already has a primary key marked on the
correct column, VID. I don't understand why the dbadapter.Updat e command
would still try to update that.

"Phil Williams" wrote:
Hi,
You could try

dsVehicle.Table s[ "vehDetail" ].RowChanged +=
new DataRowChangeEv entHandler(data Row_Change);
.
.
.
private void DataRow_Change( object sender, DataRowChangeEv entArgs e)
{
oleDbDataAdapte r1.Update(dsVeh icle, "vehDetail" );
}

All the best,
Phil.

"Alpha" wrote:
Hi, I have a datagrid and its source is a dataset. When I change information
on the grid does that automatically gets change in the dataset? If not then
how do I do that? I use the following update statement when the form is
closed to udpate the database but the changes are not there.
oleDbDataAdapte r1.Update(dsVeh icle, "vehDetail" );

Thanks, Alpha

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2431
by: PAUL EDWARDS | last post by:
I have a windows form that is bound to a datatable. In VB6 I could just update the field contents and it would be updated in the database, however if I update the text property of the control from code it is 50% chance that the update will make it back to the dataset. If I update the dataset instead of the form, it does not show on the form. Is there a method that should be used?
1
1635
by: Darryn | last post by:
Hi I am having a few problems with one of my forms... I have a data grid bound to a dataset using a currencymanager and it's all working fine. However when i edit or change any of the data in the Datagrids columns/rows i need to call update so the changes are saved back to my database, this is where the problems being. To catch the changed event of my data i have added the following events based on the Dataset Class... ...
6
4186
by: certolnut | last post by:
HI all New to C# I'm merging datasets. The source dataset is an excel file and the target dataset is in SqlServer. salesTracingCommisionNDCdataset1.Merge(ndcExcel,false,MissingSchemaAction.Error)
1
3428
by: dawn | last post by:
Hi, anyone can help me to solve this little problem that i've spent a lot of time to solve it!! but i can't!!!! actually, i use a DataGrid, and i'd like to save the changed data! ( this is just a trial method and i'll use this method with a more complique method later, that's why i can't use MxDataGrid) but each time, DataGrid save the original data, not the one after changed in the Textbox!!!
13
7666
by: abdoly | last post by:
i wrote a code to update datagrid with the datagrid updatecommand but i cant get the updated values after being update that is the code private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) TextBox temp temp=(TextBox)e.Item.Cells.Controls String str=temp.Text; str always returnt the old value of the cell (before being updated) would u plz tell me about whats wrong i m doin
3
2210
by: D. Shane Fowlkes | last post by:
I have a Datagrid which in theory, should allow you to edit and update the records. I've stripped my test page down so that it's only attempting to update one field - "description". Yet when I make the changes and click Update, it reverts back to the old value. I'm stumped! I've also checked the db table and it is infact not updating. I'm attempting to follow and example right out of ASP.NET Unleashed but not having much luck. Any...
13
2644
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value. My probelm.... when I have the user press the update button (which does a post back that loops through the datagrid and updates a database) the field/cell that is filled by the javascript appears to be blank in my update code, even though I can...
4
2146
by: Jonathan Upright | last post by:
Greetings to anyone who can help: I'm using WebMatrix to make ASP.NET pages, and I chose the "Editable DataGrid" at the project selector screen. As you may know, it defaults to the Microsoft SQL database "pubs". I've followed the instructions in the comments and also changed everything pertaining to SQL over to OLEDB. (i.e. Changed SqlDbType. to OleDbType.) I also changed the datafield names and variable names accordingly. The page...
5
1585
by: Earl | last post by:
I want to fire a database update off of a single change to a single cell in the datagrid. This apparently cannot be done using keypress, keyup, keydown, etc. I've read George Shepard's FAQ and while I may have overlooked it, I have not found an answer. I now am using the CurrentCellChanged event, and this is satisfactory IF the user moves off of the cell before closing the form. An obvious alternative would be to check for changes before...
0
1747
by: Erik | last post by:
Why isn't my update method getting called? Pasted below is an aspx from a 1.1 application I'm working on. It has two textboxes and a button for inserting data into the database, and a datagrid for editing and deleting data. When a user clicks on the "Edit" button in the datagrid, Edit() method is called and the appropriate row is changed into textboxes. And if user clicks on the "Update" button, the Update() method is fired. But if...
0
8312
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
8827
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
8732
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
8504
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,...
0
7337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4159
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
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.