数据值字段如何存储在DB表中 [英] data value field how to store in the DB table

查看:89
本文介绍了数据值字段如何存储在DB表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CREATE TABLE [dbo]。[注册](

[ID] [int] IDENTITY(1,1)NOT NULL,

[FirstName] [nvarchar] (50)NULL,

[LastName] [nvarchar](50)NULL,

[用户名] [nvarchar](50)NULL,

[电子邮件] [nvarchar](50)空,

[密码] [nvarchar](50)空,

[角色] [nvarchar](50)NULL,

[电话] [int] NULL,

[OrganisationID] [int] NOT NULL,

[CreatedAt] [datetime] NULL CONSTRAINT [ DF__Register__Create__3D2915A8] DEFAULT(getdate()),

CONSTRAINT [PK_Register] PRIMARY KEY CLUSTERED

这是我创建的表。这里的组织ID是外键,来了到我的设计部分





i有

名字,别名,电话,电子邮件,密码,角色,组织名称输入这些详细信息后,点击提交按钮即可获得错误:





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 :


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.

推荐答案

所以表''资源管理.dbo.Register''本身就说出来了不接受''OrganisationID''的空值。



所以设置这样的空值,



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





否则从代码中传递OrganisationID。



Otherwise pass OrganisationID from Your code.


查看你的表创建查询



see your table creation query

[OrganisationID] [int] NOT NULL,



表示你​​不能输入该列的NULL值。



您必须修改 [OrganisationID ] 允许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.


这篇关于数据值字段如何存储在DB表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆