I know there are several questions related to this, but I trued them it did not work.
I have an sp to insert datas into a table, the table has foreign keys as well.
This is the structure of my table that I want to insert,
Iam using asp.net and my sp looks like below
ALTER PROCEDURE [dbo].[spInsertJob]
@CompanyID INT,
@DepartmentID INT,
@No VARCHAR(50),
@Date DATETIME,
@CustomerID INT,
@JobTypeID INT,
@BillNo VARCHAR(50),
@GoodsType VARCHAR(50),
@Remarks VARCHAR(250),
@Cancelled BIT,
@CancelledRemarks VARCHAR(50),
@UserId INT,
@Closed BIT,
@Shipper VARCHAR(100),
@SupplierInvoice VARCHAR(50),
@HBillNo VARCHAR(50),
@JobStartedDate DATETIME,
@AssignedStaffid INT,
@VesselorFlightName VARCHAR(100),
@VesselorFlightArvDate DATETIME,
@FormNumber VARCHAR(50),
@FinancialId INT,
@NoofPackages INT,
@TypeOfPackages VARCHAR(100),
@ChargableWeight VARCHAR(50),
@Volume VARCHAR(50),
@DispatchMode VARCHAR(500),
@TransactionId INT OUT,
@TransactionNo NVARCHAR(50) OUT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Id AS INT
SELECT @Id=isnull(max(Id),0)+1 FROM Job
INSERT INTO Job( Id, CompanyID, DepartmentID, No, Date, CustomerID, JobTypeID, BillNo, GoodsType, Remarks, Cancelled, CancelledRemarks, UserId, Closed, Shipper, SupplierInvoiceNo, HBillNo, JobStartedDate, AssignedStaffid, VesselorFlightName, VesselorFlightArvDate, FormNumber, NoOfPackages, TypeOfPackages, ChargableWeight, Volume, DispatchMode)
values(@Id,@CompanyID,@DepartmentID,@No,@Date,@CustomerID,@JobTypeID,@BillNo,@GoodsType,@Remarks,@Cancelled,@CancelledRemarks,@UserId,@Closed,@Shipper,@SupplierInvoice,@HBillNo,@JobStartedDate,@AssignedStaffid,@VesselorFlightName,@VesselorFlightArvDate, @FormNumber,@NoofPackages, @TypeOfPackages, @ChargableWeight, @Volume, @DispatchMode)
SELECT @TransactionId = @Id
SELECT @TransactionNo = @No
SET NOCOUNT OFF;
END
I got error
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Job_JobType". The conflict occurred in database "dbname", table "dbo.JobType".
The statement has been terminated.
this is my JobType table
so I tried to insert like this and error remains
INSERT INTO Job (Id,CompanyID,DepartmentID,No,Date,CustomerID,JobTypeID,BillNo,GoodsType,Remarks,Cancelled,CancelledRemarks,UserId,Closed,Shipper,SupplierInvoiceNo,HBillNo,JobStartedDate,AssignedStaffid,VesselorFlightName,VesselorFlightArvDate,FormNumber,NoOfPackages,TypeOfPackages,ChargableWeight,Volume,DispatchMode)
VALUES (88,1,0,'test',2018-01-01,13,1,3246,'','',0,'',2,0,'','',234632,2018-01-01,1,'test',2018-01-01,'',1,0,'','0','');