Solved

Can a DatagridView suspend primary key contraints while editing?

Posted on 2014-03-17
2
277 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now