473,406 Members | 2,467 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,406 software developers and data experts.

Help with SQL Mobile and data sets

RedSon
5,000 Expert 4TB
HELP!

Expand|Select|Wrap|Line Numbers
  1. private void dataGridView1_UserAddedRow(object sender, DataGridViewRowEventArgs e)
  2.         {
  3.             MessageBox.Show("dataGridView1_UserAddedRow");
  4.             if (this.bookDataSet.HasChanges())
  5.             {
  6.                 DataSet changes = this.bookDataSet.GetChanges();
  7.  
  8.                 this.booksTableAdapter.Connection.Open();
  9.                 this.booksTableAdapter.Update((BookApplication.bookDataSet)changes);
  10.                 this.booksTableAdapter.Connection.Close();
  11.                 this.bookDataSet.Merge(changes, true, MissingSchemaAction.Add);
  12.  
  13.                 DataRow[] errRows = this.bookDataSet.Tables["books"].GetErrors();
  14.                 foreach (DataRow errRow in errRows)
  15.                 {
  16.                     errRow.RejectChanges();
  17.                     errRow.RowError = null;
  18.                 }
  19.                 this.bookDataSet.AcceptChanges();
  20.             }
  21.         }
The issue is when the user adds a row it throws an unhandled exception of type 'System.Data.ConstraintException' occurred in System.Data.dll, but the only constraints that the DB has is that none of the columns can be null. But the user has not finished entering in the information into the datagridview yet so some of the colums will be null. I don't know what the heck is going on with this. I'm at my wits end....MSDN sucks.
Feb 17 '08 #1
3 1138
kenobewan
4,871 Expert 4TB
The issue is when the user adds a row it throws an unhandled exception of type 'System.Data.ConstraintException' occurred in System.Data.dll, but the only constraints that the DB has is that none of the columns can be null. But the user has not finished entering in the information into the datagridview yet so some of the colums will be null. I don't know what the heck is going on with this. I'm at my wits end....MSDN sucks.
You have described the problem exactly. Either nulls are allowed or all columns changes are inserted at the same time. Consequently, all changes would need to be identified on one event (maybe tricky) or each change event updates all columns with new or current values (pretty inefficient).

Would it be helpful to identfy only the changes to update and use these as parameters, rather than using one update statement in the dataadapter (updating everything?). I use stored procedures for these, but only sqlcommands available to you. HTH.
Feb 18 '08 #2
RedSon
5,000 Expert 4TB
You have described the problem exactly. Either nulls are allowed or all columns changes are inserted at the same time. Consequently, all changes would need to be identified on one event (maybe tricky) or each change event updates all columns with new or current values (pretty inefficient).

Would it be helpful to identfy only the changes to update and use these as parameters, rather than using one update statement in the dataadapter (updating everything?). I use stored procedures for these, but only sqlcommands available to you. HTH.
I guess I need to know what event is triggered when the user finishes editing a row. Then I can call getChanges then and I will have all values in each column and not need to worry about null values.
Feb 18 '08 #3
RedSon
5,000 Expert 4TB
I guess I need to know what event is triggered when the user finishes editing a row. Then I can call getChanges then and I will have all values in each column and not need to worry about null values.
I think I got it figured out. The problem was with the merge call. The data set that the user updates already has the changes so mergeing them just merges double the data, and when you have values that must be unique it throws errors.
Feb 18 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: Paul Sneddon | last post by:
Hi, I'm using VS.NET 2005 RC to create Windows Mobile apps. I'm trying to call the following shell function which is new on Windows Mobile 5. SNDGETSND...
4
by: DOTNET | last post by:
Hi, Anybody help me regarding this error: I am assigning the values to the session variables when the button is clicked and passing these session variables to the next page and when I am...
2
by: rufpirat | last post by:
Hello I'm in the middle of trying to build an "AD phone book", and this being my first try at asp.net, I have a few questions that I hope some of you might be able to help with: 1. Is it...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
2
by: MK | last post by:
Hello, I am new to XML and PERL and I have a few questions the answers to which I need to complete a project. All your time and effort would be highly appreciated. I have to make a small HTML page...
1
by: shauna | last post by:
hi, i am an As level student studying Applied ICT, im having problems with normalisation. our problem is to computerise a made up business.mine for example is a beauty salon. below are my...
1
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I'm trying to figure out how you do the most basic Data-Bound "Repeater" functionality on a Mobile ASPX page. I don't mean a list box, because it will have repeated HTML and User Controls in...
0
by: Tommy152 | last post by:
I have a drop down box with a list of tables from a SQL CE database running on Windows Mobile 5, and once a user selects a table, all the data is bound to a datagrid. Now I'm trying to format the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
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...

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.