无法将值NULL插入列'emp_num',表'comp.task.dbo.employee';列不允许空值。 INSERT失败。该语句已终止。 [英] Cannot insert the value NULL into column 'emp_num', table 'comp.task.dbo.employee'; column does not allow nulls. INSERT fails. The statement has been terminated.
本文介绍了无法将值NULL插入列'emp_num',表'comp.task.dbo.employee';列不允许空值。 INSERT失败。该语句已终止。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Private Sub dept_num_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dept_num.TextChanged
Dim con As SqlConnection = New SqlConnection("Data Source=S-MHAMEED\SQL2008RTWO;Initial Catalog=comp.task;User ID=..;Password=...")
Using (con)
Dim dt As New DataTable
Dim sqlCom As New SqlCommand()
Dim sqlDA As New SqlDataAdapter()
sqlCom.Connection = con
sqlCom.CommandText = "insert_emp"
sqlCom.CommandType = CommandType.StoredProcedure
sqlCom.Parameters.AddWithValue("DEBT_NUM", Val(dept_num.Text))
sqlDA = New SqlDataAdapter(sqlCom)
sqlDA.Fill(dt)
If dt.Rows.Count Then
dept_name.Text = dt.Rows(0).Item("debt_name")
emp_num.Text = dt.Rows(0).Item("debt_emp")
End If
End Using
End Sub
我是什么尝试过:
What I have tried:
Cannot insert the value NULL into column ''emp_num'', table ''comp.task.dbo.Employee''; column does not allow nulls. INSERT fails. The statement has been terminated.
推荐答案
错误信息非常明确:
The error message is pretty explicit:
Cannot insert the value NULL into column 'emp_num', table 'comp.task.dbo.Employee'; column does not allow nulls.
Employee $ c的
emp_num
列$ c> table定义为 NOT NULL
,但是你的INSERT操作没有提供值。
要么提供值(推荐)或更改表定义。
The emp_num
column of the Employee
table is defined as NOT NULL
, but your INSERT operation is not providing a value.
Either provide a value (recommended) or change the table definition.
这篇关于无法将值NULL插入列'emp_num',表'comp.task.dbo.employee';列不允许空值。 INSERT失败。该语句已终止。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文