Jes Sie

Jes Sie

  • 702
  • 1.2k
  • 264.4k

Implicit conversion from data type datetime to int is not al

Oct 20 2017 3:31 AM
I am having the error below:
  1. Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query.  
  2.   
  3. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.   
  4.   
  5. Exception Details: System.Data.SqlClient.SqlException: Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query.  
this is when trying to insert values to my table. Below is my table structure:
  1. CREATE TABLE [dbo].[TaxInvoiceDetails_Book](  
  2.     [ID] [int] IDENTITY(1,1) NOT NULL,  
  3.     [TransactionDate] [dateNULL,  
  4.     [TransactionNo] [nvarchar](50) NULL,  
  5.     [TaxInvoiceNumber] [nvarchar](50) NULL,  
  6.     [CustomerNo] [nvarchar](50) NOT NULL,  
  7.     [CustomerName] [nvarchar](50) NULL,  
  8.     [MotorCINo] [intNULL,  
  9.     [ProductType] [nvarchar](50) NULL,  
  10.     [OrigNetPremium] [decimal](18, 2) NULL,  
  11.     [OrigVAT] [decimal](18, 2) NULL,  
  12.     [OrigRegistryFee] [decimal](18, 2) NULL,  
  13.     [TotalPremium] [decimal](18, 2) NULL,  
  14.     [AgentGrossCommission] [decimal](18, 2) NULL,  
  15.     [AgentTax] [decimal](18, 2) NULL,  
  16.     [AgentNetCommission] [decimal](18, 2) NULL,  
  17.     [ConvertedNetPremium] [decimal](18, 2) NULL,  
  18.     [ConvertedVAT] [decimal](18, 2) NULL,  
  19.     [ConvertedRegistryFee] [decimal](18, 2) NULL,  
  20.     [ConvertedTotalPremium] [decimal](18, 2) NULL,  
  21.     [ControlNumber] [nvarchar](50) NULL,  
  22.     [InsuranceType] [nvarchar](50) NULL,  
  23.     [InsuranceOption] [nvarchar](50) NULL,  
  24.     [NCD] [char](10) NULL,  
  25.     [SumInsured] [decimal](18, 2) NULL,  
  26.     [CashierID] [nvarchar](50) NULL,  
  27.     [BranchID] [nchar](10) NULL,  
  28.     [AgentID] [nvarchar](50) NULL,  
  29.  CONSTRAINT [PK_TaxInvoiceDetails_Book] PRIMARY KEY CLUSTERED   
  30. (  
  31.     [ID] ASC  
  32. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ONON [PRIMARY]  
  33. ON [PRIMARY]  
Below is my Stored Proc
  1. ALTER PROCEDURE [dbo].[spInsertToTaxInvoiceDetails_Book]  
  2.     -- Add the parameters for the stored procedure here  
  3.             (  
  4.               
  5.             @TransactionDate date,  
  6.            @TransactionNo nvarchar(50),  
  7.            @TaxInvoiceNumber nvarchar(50),  
  8.            @CustomerNo nvarchar(50),  
  9.            @CustomerName nvarchar(50),  
  10.            @MotorCINo int,  
  11.            @ProductType nvarchar(50),  
  12.            @OrigNetPremium decimal(18,2),  
  13.            @OrigVAT decimal(18,2),  
  14.            @OrigRegistryFee decimal(18,2),  
  15.            @TotalPremium decimal(18,2),  
  16.            @AgentGrossCommission decimal(18,2),  
  17.            @AgentTax decimal(18,2),  
  18.            @AgentNetCommission decimal(18,2),  
  19.            @ConvertedNetPremium decimal(18,2),  
  20.            @ConvertedVAT decimal(18,2),  
  21.            @ConvertedRegistryFee decimal(18,2),  
  22.            @ConvertedTotalPremium decimal(18,2),  
  23.            @ControlNumber nvarchar(50),  
  24.            @InsuranceType nvarchar(50),  
  25.            @InsuranceOption nvarchar(50),  
  26.            @NCD char(10),  
  27.            @SumInsured decimal(18,2),  
  28.            @CashierID nvarchar(50),  
  29.            @BranchID nchar(10),  
  30.            @AgentID nvarchar(50))  
  31. AS  
  32. BEGIN  
  33.     -- SET NOCOUNT ON added to prevent extra result sets from  
  34.     -- interfering with SELECT statements.  
  35.     SET NOCOUNT ON;  
  36.   
  37.     -- Insert statements for procedure here  
  38.     INSERT INTO [dbo].[TaxInvoiceDetails_Book]  
  39.            ([TransactionDate]  
  40.            ,[TransactionNo]  
  41.            ,[TaxInvoiceNumber]  
  42.            ,[CustomerNo]  
  43.            ,[CustomerName]  
  44.            ,[MotorCINo]  
  45.            ,[ProductType]  
  46.            ,[OrigNetPremium]  
  47.            ,[OrigVAT]  
  48.            ,[OrigRegistryFee]  
  49.            ,[TotalPremium]  
  50.            ,[AgentGrossCommission]  
  51.            ,[AgentTax]  
  52.            ,[AgentNetCommission]  
  53.            ,[ConvertedNetPremium]  
  54.            ,[ConvertedVAT]  
  55.            ,[ConvertedRegistryFee]  
  56.            ,[ConvertedTotalPremium]  
  57.            ,[ControlNumber]  
  58.            ,[InsuranceType]  
  59.            ,[InsuranceOption]  
  60.            ,[NCD]  
  61.            ,[SumInsured]  
  62.            ,[CashierID]  
  63.            ,[BranchID]  
  64.            ,[AgentID])  
  65.      VALUES  
  66.            (@TransactionDate,   
  67.            @TransactionNo,   
  68.            @TaxInvoiceNumber,   
  69.            @CustomerNo,   
  70.            @CustomerName,   
  71.            @MotorCINo,   
  72.            @ProductType,  
  73.            @OrigNetPremium,   
  74.            @OrigVAT,   
  75.            @OrigRegistryFee,   
  76.            @TotalPremium,   
  77.            @AgentGrossCommission,   
  78.            @AgentTax,   
  79.            @AgentNetCommission,   
  80.            @ConvertedNetPremium,   
  81.            @ConvertedVAT,   
  82.            @ConvertedRegistryFee,   
  83.            @ConvertedTotalPremium,   
  84.            @ControlNumber,   
  85.            @InsuranceType,   
  86.            @InsuranceOption,   
  87.            @NCD,   
  88.            @SumInsured,   
  89.            @CashierID,  
  90.            @BranchID,   
  91.            @AgentID)  
Thank in advance for any assistance. 
 
 
 

Answers (3)