error in cmd.Parameters.AddWithValue

  • Thread starter Thread starter Omi4u
  • Start date Start date
O

Omi4u

Guest
Dear All


Why i am getting this error in below code

The parameterized query '(@d60 datetime,@d61 nvarchar(8),@d62 nvarchar(4000),@d63 nvarcha' expects the parameter '@d71', which was not supplied.



Dim cb2 As String = "insert into ledgerdetails(date,transactionid,description,debit,credit,balance,coaiddr,accountnamedr,coaidcr,accountnamecr,userid,blncecr) VALUES (@d60,@d61,@d62,@d63,@d64,@d65,@d66,@d67,@d68,@d69,@d70,@d71)"
cmd = New SqlCommand(cb2)
cmd.Connection = con
' Prepare command for repeated execution
cmd.Prepare()
' Data to be inserted
For Each row As DataGridViewRow In CashpaymentDataGridView.Rows
If Not row.IsNewRow Then
cmd.Parameters.AddWithValue("@d60", row.Cells(2).Value) 'date
cmd.Parameters.AddWithValue("@d61", "CPV" & "" & row.Cells(1).Value) 'transactionid
cmd.Parameters.AddWithValue("@d62", row.Cells(9).Value) 'description
cmd.Parameters.AddWithValue("@d63", row.Cells(7).Value) 'debit
cmd.Parameters.AddWithValue("@d64", row.Cells(8).Value) 'credit
cmd.Parameters.AddWithValue("@d65", row.Cells(11).Value) 'balance
cmd.Parameters.AddWithValue("@d66", row.Cells(3).Value) 'coaiddr
cmd.Parameters.AddWithValue("@d67", row.Cells(4).Value) 'accountnamedr
cmd.Parameters.AddWithValue("@d68", row.Cells(5).Value) 'coaidcr
cmd.Parameters.AddWithValue("@d69", row.Cells(6).Value) 'accountnamecr
cmd.Parameters.AddWithValue("@d70", row.Cells(10).Value) 'userid
cmd.Parameters.AddWithValue("@d71", row.Cells(12).Value) 'userid


' cmd.Parameters.AddWithValue("@d10", row.Cells(9).Value) 'userid
cmd.ExecuteNonQuery()
cmd.Parameters.Clear()
End If
Next
con.Close()

Continue reading...
 
Back
Top