Solved

Can a DatagridView suspend primary key contraints while editing?

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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
Viewers will learn how the fundamental information of how to create a table.

756 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