Click here to Skip to main content
15,901,853 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
CREATE TABLE [dbo].[Register](
[ID] [int] IDENTITY(1,1) NOT NULL,
[FirstName] [nvarchar](50) NULL,
[LastName] [nvarchar](50) NULL,
[Username] [nvarchar](50) NULL,
[Email] [nvarchar](50) NULL,
[Password] [nvarchar](50) NULL,
[Role] [nvarchar](50) NULL,
[Phone] [int] NULL,
[OrganisationID] [int] NOT NULL,
[CreatedAt] [datetime] NULL CONSTRAINT [DF__Register__Create__3D2915A8] DEFAULT (getdate()),
CONSTRAINT [PK_Register] PRIMARY KEY CLUSTERED
this is the table which i have created. here the organisation ID is foreign key and coming to my design part


i have
firstname, alstname,phone,email,password,role,organisationame after entering these these details, and clicked on submit button i m getting error as :


SQL
Cannot insert the value NULL into column 'OrganisationID', table 'Resource Management.dbo.Register'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Posted
Updated 10-Jan-13 20:28pm
v5
Comments
Sandeep Mewara 11-Jan-13 1:58am    
Your question is not clear. You want to insert the dropdown field into which table and when?

Workflow? Someone in UI selects something in drodpown and then you want to save that in your database? OR you want to directly pick some value from table 1 in DB and save in Table2?

What is the role of dropdownlist herE?
prashant patil 4987 11-Jan-13 2:05am    
hey angelina:
be clear your question... specify details of your question...

So the Table 'Resource Management.dbo.Register' itself say it wont accepts the null values for 'OrganisationID'.

So set the null value like this,

[OrganisationID] [int]= NULL


Otherwise pass OrganisationID from Your code.
 
Share this answer
 
Comments
Dhritirao's 11-Jan-13 2:40am    
my doubt is how to pass the organisationid from the code
Sanjeev Alamuri 11-Jan-13 2:43am    
so u have dropdown which contains OrganisationName and OrganisationId, the get the value of dropdown selected value by this,

int OrganisationID= int.Parse(drpOrganisaiton.SelectedVlaue);.
see your table creation query

SQL
[OrganisationID] [int] NOT NULL,

that's mean you can't enter the NULL value for that column.

Either you have to modify the [OrganisationID] to allow NULL or you have to insert the integer value for that column.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900