473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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(object sender, EventArgs e) {
try {

CustomerDataSetTableAdapters.TableAdapterManager taManager = new
CustomerDataSetTableAdapters.TableAdapterManager() ;
taManager.PostsTableAdapter = postsTableAdapter;
taManager.PostDetailsTableAdapter = postDetailsTableAdapter;
postsBindingSource.EndEdit();
postsDetailsBindingSource.EndEdit();
taManager.UpdateAll(customerDataSet);
}
catch (System.Exception ex) {
MessageBox.Show(ex.Message.ToString());
}

}

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 2355
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***@discussions.microsoft.comwrote in message
news:F4**********************************@microsof t.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(object sender, EventArgs e) {
try {

CustomerDataSetTableAdapters.TableAdapterManager taManager = new
CustomerDataSetTableAdapters.TableAdapterManager() ;
taManager.PostsTableAdapter = postsTableAdapter;
taManager.PostDetailsTableAdapter = postDetailsTableAdapter;
postsBindingSource.EndEdit();
postsDetailsBindingSource.EndEdit();
taManager.UpdateAll(customerDataSet);
}
catch (System.Exception ex) {
MessageBox.Show(ex.Message.ToString());
}

}

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***@discussions.microsoft.comwrote in message
news:F4**********************************@microsof t.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(object sender, EventArgs e) {
try {

CustomerDataSetTableAdapters.TableAdapterManager taManager = new
CustomerDataSetTableAdapters.TableAdapterManager() ;
taManager.PostsTableAdapter = postsTableAdapter;
taManager.PostDetailsTableAdapter = postDetailsTableAdapter;
postsBindingSource.EndEdit();
postsDetailsBindingSource.EndEdit();
taManager.UpdateAll(customerDataSet);
}
catch (System.Exception ex) {
MessageBox.Show(ex.Message.ToString());
}

}

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
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...
5
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...
18
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...
0
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....
3
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...
9
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...
0
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...
1
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...

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.