错误:没有给出一个或多个必需参数的值

时间:2017-05-16 10:11:05

标签: vb.net

 $("#txtdoe").datepicker({ minDate: 0 });

我得到的错误没有给出一个或多个必需参数的值。参数在保存时工作正常,但无法更新。

1 个答案:

答案 0 :(得分:0)

您的Field BankName和ReferenceNo

旁边有一个额外的@

<强> @ BANKNAME = @名称 @ ReferenceNo = @ REF

myconnection() 'open connection

sql = "UPDATE tblbankposting SET BankEntryDate=@date,BankName=@name,BankCode=@code,AccountNo=@acc"
sql &= ",TransactionType=@type,Amount=@amount,BankCharges=@charges,ReferenceNo=@ref,Description=@des "
sql &= "WHERE TransactionID=@id"

command = New OleDbCommand(sql, connection)
With command
    .Parameters.Add(New OleDbParameter("@id", OleDbType.VarChar, 30, "TransactionID"))
    .Parameters.Add(New OleDbParameter("@date", OleDbType.DBDate, 30, "BankEntryDate"))
    .Parameters.Add(New OleDbParameter("@name", OleDbType.VarChar, 30, "BankName"))
    .Parameters.Add(New OleDbParameter("@code", OleDbType.VarChar, 30, "BankCode"))
    .Parameters.Add(New OleDbParameter("@acc", OleDbType.VarChar, 30, "AccountNo"))
    .Parameters.Add(New OleDbParameter("@type", OleDbType.VarChar, 30, "TransactionType"))
    .Parameters.Add(New OleDbParameter("@amount", OleDbType.Double, 10, "Amount"))
    .Parameters.Add(New OleDbParameter("@charges", OleDbType.Double, 10, "BankCharges"))
    .Parameters.Add(New OleDbParameter("@ref", OleDbType.VarChar, 30, "ReferenceNo"))
    .Parameters.Add(New OleDbParameter("@des", OleDbType.VarChar, 30, "Description"))
    'set parameter values
    .Parameters("@id").Value = txttxnid.Text
    .Parameters("@date").Value = CDate(dtpbankentrydate.Value.Date)
    .Parameters("@name").Value = cbobanks.Text
    .Parameters("@code").Value = txtbankcode.Text
    .Parameters("@acc").Value = cboaccno.Text
    .Parameters("@type").Value = cbotxntype.Text
    .Parameters("@amount").Value = CDbl(txtamount.Text)
    .Parameters("@charges").Value = CDbl(txtbankcharges.Text)
    .Parameters("@ref").Value = txtrefno.Text
    .Parameters("@des").Value = txtdescription.Text
End With