【问题标题】:An SqlParameter with ParameterName '@OE_PurchaseDate' is not contained by this SqlParameterCollection此 SqlParameterCollection 不包含具有 ParameterName '@OE_PurchaseDate' 的 SqlParameter
【发布时间】:2013-05-03 07:34:06
【问题描述】:

当我将文本框更改为 datetimepicker 时出现此错误

这是我的代码

        Dim cmd As SqlCommand = sqlconn.CreateCommand
        sqlconn.Open()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "AddOfficeEquipmentProfile"
        cmd.Parameters("@OE_PurchaseDate").Value = dtpPurchaseDate.Value
        cmd.ExecuteNonQuery()
        sqlconn.close

这是我的存储过程如下

CREATE PROCEDURE AddOfficeEquipmentProfile
(

@OE_PurchaseDate    smalldatetime,      

)
AS

INSERT INTO tblOfficeEquipmentProfile (OE_PurchaseDate) 
VALUES (@OE_PurchaseDate)
GO

【问题讨论】:

  • 你的存储过程AddOfficeEquipmentProfile是否包含一个名为OE_PurchaseDate的参数?
  • 是的先生,请看看我的存储过程

标签: sql vb.net visual-studio-2008


【解决方案1】:

我认为错误信息非常简单。在尝试设置其值之前,您需要add the parameter

cmd.CommandText = "AddOfficeEquipmentProfile"
cmd.Parameters.Add("@OE_PurchaseDate",SqlDbType.SmallDateTime)
cmd.Parameters("@OE_PurchaseDate").Value = dtpPurchaseDate.Value

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-17
    • 1970-01-01
    相关资源
    最近更新 更多