Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can a DatagridView suspend primary key contraints while editing?

Posted on 2014-03-17
2
Medium Priority
?
284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
lcohan earned 1500 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

721 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