Solved

Can a DatagridView suspend primary key contraints while editing?

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

708 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

20 Experts available now in Live!

Get 1:1 Help Now