0
데이터 유형 datetime에서 tinyint로 암시 적 변환이 허용되지 않습니다. CONVERT 함수를 사용하여이 쿼리를 실행합니다. 나는 Varchar와 데이트하고있어 오류입니다 tjhe 나는 이것과 함께 정상적인 문제를 알고 있지만이 하나 알아낼 것 같지 않습니다.데이터 변환 날짜가 int 일 때 오류가 발생했지만 모두 일치하는 것처럼 보입니다.
Public Function SavePropertyExpiries() As Boolean
'** Save Current Personal Data Record
' Error Checking
'On Error GoTo Err_SaveProperty
' Dimension Local Variables
Dim uRecSnap As ADODB.Recordset
' Check For Open Connection
If uDBase Is Nothing Then
OpenConnection()
bConnection = True
End If
' Run Stored Procedure - Save PropertyExpiries Record
uCommand = New ADODB.Command
With uCommand
.ActiveConnection = uDBase
.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
.CommandTimeout = 0
uCommand.Parameters.Append(uCommand.CreateParameter("@PropertyID", ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamInput, , Val(lblPropertyIDValue.Text)))
uCommand.Parameters.Append(uCommand.CreateParameter("@HMOLicenced", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , -chkHMOLicenced.Checked))
uCommand.Parameters.Append(uCommand.CreateParameter("@HMOExpiryDate", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput, , dtpHMOExpiryDate.Value))
uCommand.Parameters.Append(uCommand.CreateParameter("@HMOLicenseRef", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 60, txtHMOLicenseRef.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@HMONotes", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 100, txtHMONotes.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@GasSafetyCheck", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , -chkGasSafetyCheck.Checked))
uCommand.Parameters.Append(uCommand.CreateParameter("@GasSafetyExpiryDate", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput, , dtpGasSafetyExpiryDate.Value))
uCommand.Parameters.Append(uCommand.CreateParameter("@GasSafetyNotes", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 100, txtGasSafetyNotes.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@PAT", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , -chkPAT.Checked))
uCommand.Parameters.Append(uCommand.CreateParameter("@PATExpiryDate", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput, , dtpPATExpiryDate.Value))
uCommand.Parameters.Append(uCommand.CreateParameter("@PATNotes", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 100, txtPATNotes.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@EICR", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , -chkEICR.Checked))
uCommand.Parameters.Append(uCommand.CreateParameter("@EICRExpiryDate", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput, , dtpEIRCExpiryDate.Value))
uCommand.Parameters.Append(uCommand.CreateParameter("@EICRNotes", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 100, txtEIRCNotes.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@FireSafety", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , -chkFireSafety.Checked))
uCommand.Parameters.Append(uCommand.CreateParameter("@FiresafetyExpiryDate", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput, , dtpFiresafetyExpiryDate.Value))
uCommand.Parameters.Append(uCommand.CreateParameter("@FireSafetyNotes", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 100, txtFiresafetyNotes.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@EPC", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , -chkEPC.Checked))
uCommand.Parameters.Append(uCommand.CreateParameter("@EPCExpiryDate", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput, , dtpEPCExpiryDate.Value))
uCommand.Parameters.Append(uCommand.CreateParameter("@EPCRating", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , cmbEPCRating.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@EPCNotes", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 100, txtEPCNotes.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@Insurance", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , -chkInsurance.Checked))
uCommand.Parameters.Append(uCommand.CreateParameter("@InsurenceExpiryDate", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput, , dtpInsurenceExpiryDate.Value))
uCommand.Parameters.Append(uCommand.CreateParameter("@InsurenceNotes", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 100, txtInsurenceNotes.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@PropertyInspection", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , -chkPropertyInspection.Checked))
uCommand.Parameters.Append(uCommand.CreateParameter("@PropertyInspectionDate", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput, , dtpPropertyInspectionDate.Value))
uCommand.Parameters.Append(uCommand.CreateParameter("@PropertyInspectionInMonths", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , nudPropertyInspectionInMonths.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@PropertyInspectionNotes", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 100, txtPropertyInspectionNotes.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@LandLordRegistration", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , -chkLandLordRegistration.Checked))
uCommand.Parameters.Append(uCommand.CreateParameter("@LandLordRegistrationExpiryDate", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput, , dtpLandLordRegistrationExpiryDate.Value))
uCommand.Parameters.Append(uCommand.CreateParameter("@LandlordRegistrationNo", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 100, txtLandlordRegistrationNo.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@LandlordRegistrationNotes", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 100, txtLandlordRegistrationNotes.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@NextRentReview", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , -chkNextRentReview.Checked))
uCommand.Parameters.Append(uCommand.CreateParameter("@NextRentReviewExpiryDate", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput, , dtpNextRentReviewExpiryDate.Value))
uCommand.Parameters.Append(uCommand.CreateParameter("@NextRentreviewNotes", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 100, txtNextRentreviewNotes.Text))
uCommand.Parameters.Append(uCommand.CreateParameter("@ManagementFeeReview", ADODB.DataTypeEnum.adTinyInt, ADODB.ParameterDirectionEnum.adParamInput, , -chkManagementFeeReview.Checked))
uCommand.Parameters.Append(uCommand.CreateParameter("@ManagementExpiryDate", ADODB.DataTypeEnum.adDate, ADODB.ParameterDirectionEnum.adParamInput, , dtpManagementExpiryDate.Value))
uCommand.Parameters.Append(uCommand.CreateParameter("@ManagementfeeReviewNotes", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 100, txtManagementfeeReviewNotes.Text))
.CommandText = "PropertyExpiries_SaveRecord"
.Execute()
End With
' Close Connection
uRecSnap = Nothing
uCommand = Nothing
If bConnection Then CloseConnection()
SavePropertyExpiries = True
Err_SaveProperty:
If Err.Number <> 0 Then
sErrDescription = Err.Description
WriteAuditLogRecord("clsPropertyExpiries", "SaveExpiries", "Error", sErrDescription)
SavePropertyExpiries = False
End If
End Function
Herer는 SP의 itselft입니다 :
나는 아래의 SP를 호출하는 코드가
ALTER PROCEDURE [dbo].[PropertyExpiries_SaveRecord]
-- Add the parameters for the stored procedure here
@PropertyID as int, @HMOLicenced as tinyint, @HMOExpiryDate as date, @HMOLicenseRef as varchar(60), @HMONotes as varchar(60),
@GasSafetyCheck as tinyint, @GasSafetyExpiryDate as date, @GasSafetyNotes as varchar(100), @PAT as tinyint,
@PATExpiryDate as date, @PATNotes as varchar(60), @EICR as tinyint, @EICRExpiryDate as date, @EICRNotes as varchar(60),
@FireSafety as tinyint, @FiresafetyExpiryDate as date, @FireSafetyNotes as varchar(60), @EPC as tinyint,
@EPCExpiryDate as date, @EPCRating tinyint, @EPCNotes as varchar(60), @Insurance as tinyint, @InsurenceExpiryDate as date, @InsurenceNotes as varchar(60),
@LandlordRegistrationNo as varchar(60),@PropertyInspection as tinyint, @PropertyInspectionDate as date,
@PropertyInspectionInMonths as tinyint, @PropertyInspectionNotes as varchar(60), @LandLordRegistration as tinyint,
@LandLordRegistrationExpiryDate as date, @LandlordRegistrationNotes as varchar(60), @NextRentReview as tinyint, @NextRentReviewExpiryDate as date,
@NextRentreviewNotes as varchar(60), @ManagementFeeReview as tinyint, @ManagementExpiryDate as date, @ManagementfeeReviewNotes as varchar(60)
AS
If (SELECT ISNULL(PropertyID , 0) FROM PropertyExpiries WHERE PropertyID = @PropertyID) = 0
BEGIN
INSERT INTO PropertyExpiries (PropertyID, HMOLicenced, HMOExpiryDate, HMOLicenseRef, HMONotes, GasSafetyCheck, GasSafetyExpiryDate, GasSafetyNotes, PAT, PATExpiryDate, PATNotes, EICR, EICRExpiryDate, EICRNotes, FireSafety, FiresafetyExpiryDate, FireSafetyNotes, EPC, EPCExpiryDate, EPCRating, EPCNotes, Insurance, InsurenceExpiryDate, InsurenceNotes, PropertyInspection, PropertyInspectionDate, PropertyInspectionInMonths, PropertyInspectionNotes, LandLordRegistration, LandLordRegistrationExpiryDate, LandlordRegistrationNo, LandlordRegistrationNotes, NextRentReview, NextRentReviewExpiryDate, NextRentreviewNotes, ManagementFeeReview, ManagementExpiryDate, ManagementfeeReviewNotes)
VALUES (@PropertyID, @HMOLicenced, @HMOExpiryDate, @HMOLicenseRef, @HMONotes, @GasSafetyCheck, @GasSafetyExpiryDate, @GasSafetyNotes, @PAT, @PATExpiryDate, @PATNotes, @EICR, @EICRExpiryDate, @EICRNotes, @FireSafety, @FiresafetyExpiryDate, @FireSafetyNotes, @EPC, @EPCExpiryDate, @EPCRating, @EPCNotes, @Insurance, @InsurenceExpiryDate, @InsurenceNotes, @PropertyInspection, @PropertyInspectionDate, @PropertyInspectionInMonths, @PropertyInspectionNotes, @LandLordRegistration, @LandLordRegistrationExpiryDate, @LandlordRegistrationNo, @LandlordRegistrationNotes, @NextRentReview, @NextRentReviewExpiryDate, @NextRentreviewNotes, @ManagementFeeReview, @ManagementExpiryDate, @ManagementfeeReviewNotes)
END
BEGIN
UPDATE PropertyExpiries SET
PropertyID = @PropertyID,
HMOLicenced = @HMOLicenced,
HMOExpiryDate = @HMOExpiryDate,
HMOLicenseRef = @HMOLicenseRef,
HMONotes = @HMONotes,
GasSafetyCheck = @GasSafetyCheck,
GasSafetyExpiryDate = @GasSafetyExpiryDate,
GasSafetyNotes = @GasSafetyNotes,
PAT = @PAT,
PATExpiryDate = @PATExpiryDate,
PATNotes = @PATNotes,
EICR = @EICR,
EICRExpiryDate = @EICRExpiryDate,
EICRNotes = @EICRNotes,
FireSafety = @FireSafety,
FiresafetyExpiryDate = @FiresafetyExpiryDate,
FireSafetyNotes = @FireSafetyNotes,
EPC = @EPC,
EPCExpiryDate = @EPCExpiryDate,
EPCRating = @EPCRating,
EPCNotes = @EPCNotes,
Insurance = @Insurance,
InsurenceExpiryDate = @InsurenceExpiryDate,
InsurenceNotes = @InsurenceNotes,
PropertyInspection = @PropertyInspection,
PropertyInspectionDate = @PropertyInspectionDate,
PropertyInspectionInMonths = @PropertyInspectionInMonths,
PropertyInspectionNotes = @PropertyInspectionNotes,
LandLordRegistration = @LandLordRegistration,
LandLordRegistrationExpiryDate = @LandLordRegistrationExpiryDate,
LandlordRegistrationNo = @LandlordRegistrationNo,
LandlordRegistrationNotes = @LandlordRegistrationNotes,
NextRentReview = @NextRentReview,
NextRentReviewExpiryDate = @NextRentReviewExpiryDate,
NextRentreviewNotes = @NextRentreviewNotes,
ManagementFeeReview = @ManagementFeeReview,
ManagementExpiryDate = @ManagementExpiryDate,
ManagementfeeReviewNotes = @ManagementfeeReviewNotes
WHERE PropertyID = @PropertyID
END
테이블 :
USE [BMSSouthSide]
GO
/****** Object: Table [dbo].[PropertyExpiries] Script Date: 29/01/2015 11:04:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[PropertyExpiries](
[PropertyID] [int] NULL,
[HMOLicenced] [tinyint] NULL,
[HMOExpiryDate] [date] NULL,
[HMOLicenseRef] [varchar](100) NULL,
[HMONotes] [varchar](100) NULL,
[GasSafetyCheck] [tinyint] NULL,
[GasSafetyExpiryDate] [date] NULL,
[GasSafetyNotes] [varchar](100) NULL,
[PAT] [tinyint] NULL,
[PATExpiryDate] [date] NULL,
[PATNotes] [varchar](100) NULL,
[EICR] [tinyint] NULL,
[EICRExpiryDate] [date] NULL,
[EICRNotes] [varchar](100) NULL,
[FireSafety] [tinyint] NULL,
[FiresafetyExpiryDate] [date] NULL,
[FireSafetyNotes] [varchar](100) NULL,
[EPC] [tinyint] NULL,
[EPCExpiryDate] [date] NULL,
[EPCRating] [tinyint] NULL,
[EPCNotes] [varchar](100) NULL,
[Insurance] [tinyint] NULL,
[InsurenceExpiryDate] [date] NULL,
[InsurenceNotes] [varchar](100) NULL,
[PropertyInspection] [tinyint] NULL,
[PropertyInspectionDate] [date] NULL,
[PropertyInspectionInMonths] [tinyint] NULL,
[PropertyInspectionNotes] [varchar](100) NULL,
[LandLordRegistration] [tinyint] NULL,
[LandLordRegistrationExpiryDate] [date] NULL,
[LandlordRegistrationNo] [varchar](20) NULL,
[LandlordRegistrationNotes] [varchar](100) NULL,
[NextRentReview] [tinyint] NULL,
[NextRentReviewExpiryDate] [date] NULL,
[NextRentreviewNotes] [varchar](100) NULL,
[ManagementFeeReview] [tinyint] NULL,
[ManagementExpiryDate] [date] NULL,
[ManagementfeeReviewNotes] [varchar](100) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
내 테이블이 올라와 있습니다. @RhysJones 죄송합니다. – Richard