473,715 Members | 6,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Database updates in LINQ

I am trying to use Update to save changes made on two DataGridView's to two
tables (Posts & PostDetails) with a FK relationship. I say

private void bUpdate_Click(o bject sender, EventArgs e) {
try {

CustomerDataSet TableAdapters.T ableAdapterMana ger taManager = new
CustomerDataSet TableAdapters.T ableAdapterMana ger();
taManager.Posts TableAdapter = postsTableAdapt er;
taManager.PostD etailsTableAdap ter = postDetailsTabl eAdapter;
postsBindingSou rce.EndEdit();
postsDetailsBin dingSource.EndE dit();
taManager.Updat eAll(customerDa taSet);
}
catch (System.Excepti on ex) {
MessageBox.Show (ex.Message.ToS tring());
}

}

It doesn't work. Note:
1. Changes (just DataGridView edits to existing records) don;t show in the
databse.
2. It doen't raise an exception.
3. CustomerDataSet (in UpdateAll() line) contains the new values.

Can you help?

Thanks
Aug 15 '08 #1
2 2378
You realize what you have here is not LINQ, right?

As for the problem, try firing AcceptChanges on the DataSet prior to firing
off UpdateAll on the TableAdapter.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

*************** *************** **************
| Think outside the box! |
*************** *************** **************
"julio" <ju***@discussi ons.microsoft.c omwrote in message
news:F4******** *************** ***********@mic rosoft.com...
>I am trying to use Update to save changes made on two DataGridView's to two
tables (Posts & PostDetails) with a FK relationship. I say

private void bUpdate_Click(o bject sender, EventArgs e) {
try {

CustomerDataSet TableAdapters.T ableAdapterMana ger taManager = new
CustomerDataSet TableAdapters.T ableAdapterMana ger();
taManager.Posts TableAdapter = postsTableAdapt er;
taManager.PostD etailsTableAdap ter = postDetailsTabl eAdapter;
postsBindingSou rce.EndEdit();
postsDetailsBin dingSource.EndE dit();
taManager.Updat eAll(customerDa taSet);
}
catch (System.Excepti on ex) {
MessageBox.Show (ex.Message.ToS tring());
}

}

It doesn't work. Note:
1. Changes (just DataGridView edits to existing records) don;t show in the
databse.
2. It doen't raise an exception.
3. CustomerDataSet (in UpdateAll() line) contains the new values.

Can you help?

Thanks

Aug 16 '08 #2
Thanks for your answer.

1) Unfortunately, AcceptChanges doesn't fix the problem.

1a) ANyway, why would this work when the dataset already contains the
changes, as verified during debugging???

2) Yes, I realize that this is not link, but then again, I was (naively)
thinking that DataContext would have an Update method, but apparently it
doesn't, so at this point I don't have anything that works, Linq or
otherwise.

3) BTW the DataSet has the hierarchical updates member set to true.

JK

"Cowboy (Gregory A. Beamer)" wrote:
You realize what you have here is not LINQ, right?

As for the problem, try firing AcceptChanges on the DataSet prior to firing
off UpdateAll on the TableAdapter.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

*************** *************** **************
| Think outside the box! |
*************** *************** **************
"julio" <ju***@discussi ons.microsoft.c omwrote in message
news:F4******** *************** ***********@mic rosoft.com...
I am trying to use Update to save changes made on two DataGridView's to two
tables (Posts & PostDetails) with a FK relationship. I say

private void bUpdate_Click(o bject sender, EventArgs e) {
try {

CustomerDataSet TableAdapters.T ableAdapterMana ger taManager = new
CustomerDataSet TableAdapters.T ableAdapterMana ger();
taManager.Posts TableAdapter = postsTableAdapt er;
taManager.PostD etailsTableAdap ter = postDetailsTabl eAdapter;
postsBindingSou rce.EndEdit();
postsDetailsBin dingSource.EndE dit();
taManager.Updat eAll(customerDa taSet);
}
catch (System.Excepti on ex) {
MessageBox.Show (ex.Message.ToS tring());
}

}

It doesn't work. Note:
1. Changes (just DataGridView edits to existing records) don;t show in the
databse.
2. It doen't raise an exception.
3. CustomerDataSet (in UpdateAll() line) contains the new values.

Can you help?

Thanks

Aug 19 '08 #3

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

Similar topics

3
13069
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.
5
1954
by: Daniel Bass | last post by:
I setup a asp.net project running on http://localhost/ which connects to a database on another server running sqlserver... I was able to connect to the database and create my application no problem. The sqlserver database server had windows 2000 without any SP's or updates. This was no problem and even though the OS hadn't the .net framework installed, everything worked fine. the requirements for that sqlserver database server have...
18
9143
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft page "How to: Connect to Data in an Access Database"
0
2920
by: D0c | last post by:
Hey, I would like to syncronize my local database with my website database. Scenarios are 1. New rows / row updates in the local database to be updated on the website database (local -net) 2. Updates on the website database to be updated on the local database (net -local) * Updates for both databases are possibly on different fields
3
1933
by: plonk | last post by:
Hi I'm trying to learn sql by getting a database up and running on VB.net 2008 and SQL server express. I have the database connected correctly, (i think) but when i try to add a record using this code.. Dim db As New racedataDataContext Dim newmeeting As MeetingInfo = New MeetingInfo newmeeting.Date = Today db.MeetingInfos.add(newmeeting)
9
2503
by: =?Utf-8?B?cmF1bGF2aQ==?= | last post by:
Hi all: after reading different places/sites about linq... I ran into these questions: 1. What framework do we need to run linq ? (does it depend on what version of visual studio we have?) how about vs2008? is it different name space or framework for linq xml or linq sql? ( 2. do we need to have references to what linq's dlls. or namespaces? system core? 3. what name spaces are needed?
0
2363
by: =?Utf-8?B?SHlwZXJjb2Rlcg==?= | last post by:
I'm encountering some strange behavior after deploying a ASP.net 3.5 website to production, i'm unable to reproduce these in my dev environment. This error seems to occur very randomly but it's occuring enough to be a real cause for concern. The errors occur a couple times a week and the website is hit with constant traffic 24x7. Below are the two errors that are encountered. I had read something about MARS causing errors like this but...
1
1217
by: Cowboy \(Gregory A. Beamer\) | last post by:
Just wanted to ping this off of someone and what better place to do it than here. I have the following: public void Delete(T entity) { Type type = entity.GetType(); //TODO: Can make this dynamic for flexibility string property = "IsDeleted";
2
3303
by: jelle79 | last post by:
Hi all, I'm storing all kind of data stored in objects. Now I want to query my data-source. And I thought LINQ is the right thing for it. Data is stored like: store.Database Queries like this work:
0
8718
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
9196
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
9103
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
7973
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...
1
6646
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
5967
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
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3175
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
3
2118
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.