Solved

Can a DatagridView suspend primary key contraints while editing?

Posted on 2014-03-17
2
278 Views
Last Modified: 2014-03-17
Hi,

I have a Datagridview with data binding to a datatable from a dataset.
The bound table has the following columns:

RecYear primaryKey - also foreign key in linked table
RecID primaryKey - also foreign key in linked table
SampleID PrimaryKey
SampleType
SampleCount

I want to only show two columns in the grid: SampleType and SampleCount
Inserting new data into the table is taken care of by a stored procedure which takes five parameters: @SampleType and @SampleCount.
Pluss: @RecYear', '@RecID' and  '@SampleID output'.
@RecYear', '@RecID' I will set in my Save method of the form.
The sampleID is calculated in the stored procedure. So: Output parameter only

The problem is that the datagrid and the bound datatable cannot wait with the assigning of the primary keys until I want to 'batch save' added records. The grid throws error/warning after leaving the the first new row in the grid.

Is is possible for make the bound datatable ignore lacking  null-data for primary keys until updating the table on the SQL server?

I use dataset, tableadapter and bindingsource

bw
Kai
0
Comment
Question by:lieka
2 Comments
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
ID: 39934740
"Can a DatagridView suspend primary key contraints while editing?"

[...]

"Is is possible for make the bound datatable ignore lacking  null-data for primary keys until updating the table on the SQL server?"

The answer to both of the above is NO.
Primary keys in any relational database are not allowed to be NULL.
0
 

Author Closing Comment

by:lieka
ID: 39934797
OK. Can you please give me hint how I can make the grid hold several rows of temporary (suggested) data which the user can choose to submit to the server or just discard? Any help would be much appreciated.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question