任何人都可以给出建议。为什么我会收到这个错误。
System.Data.SqlClient.SqlException:INSERT 语句与 CHECK 约束“CK_GL10000 _TRXDATE__56701F76 ”冲突。冲突发生在数据库“TWO”、表“dbo.GL10000”、列“TRXDATE”中。
这是我的存储过程:
SqlCommand myCommand1 = new SqlCommand("taGLTransactionHeaderInsert", strcon);
myCommand1.CommandType = CommandType.StoredProcedure;
myCommand1.CommandText = "taGLTransactionHeaderInsert";
myCommand1.Parameters.Add("@I_vBACHNUMB", SqlDbType.Char).Value = GLHdr.BACHNUMB;
myCommand1.Parameters.Add("@I_vREFRENCE", SqlDbType.Char).Value = "ExcelImport";
myCommand1.Parameters.Add("@I_vTRXDATE", SqlDbType.DateTime).Value = GLHdr.TRXDATE;
表定义:
CREATE TABLE [dbo].[GL10000](
[PSTGSTUS] [smallint] NOT NULL,
[LASTUSER] [char](15) NOT NULL,
[LSTDTEDT] [datetime] NOT NULL,
[USWHPSTD] [char](15) NOT NULL,
[TRXTYPE] [smallint] NOT NULL
/* More columns? not included in script that OP added */
)
GO
ALTER TABLE [dbo].[GL10000] WITH CHECK ADD CHECK
((datepart(hour,[RVRSNGDT])=(0) AND datepart(minute,[RVRSNGDT])=(0)
AND datepart(second,[RVRSNGDT])=(0) AND datepart(millisecond,[RVRSNGDT])=(0)))
GO
ALTER TABLE [dbo].[GL10000] WITH CHECK ADD CHECK
((datepart(hour,[Tax_Date])=(0) AND datepart(minute,[Tax_Date])=(0)
AND datepart(second,[Tax_Date])=(0) AND datepart(millisecond,[Tax_Date])=(0)))
GO
ALTER TABLE [dbo].[GL10000] WITH CHECK ADD CHECK
((datepart(day,[TIME1])=(1) AND datepart(month,[TIME1])=(1)
AND datepart(year,[TIME1])=(1900)))
GO
ALTER TABLE [dbo].[GL10000] WITH CHECK ADD CHECK
((datepart(hour,[TRXDATE])=(0) AND datepart(minute,[TRXDATE])=(0)
AND datepart(second,[TRXDATE])=(0) AND datepart(millisecond,[TRXDATE])=(0)))
GO
ALTER TABLE [dbo].[GL10000] ADD CONSTRAINT
[DF__GL10000__DEX_ROW__540C7B00] DEFAULT (getutcdate()) FOR [DEX_ROW_TS]
GO