AM trying to update but get this error
syntax near '='
What I have tried:
con = New SqlConnection(cs)
con.Open()
Dim cb As String = "Update CourseFeePayment set CFP_ID=@d1, PaymentID=@d2, AdmissionNo=@d3, Session=@d4,TotalFee=@d6, DiscountPer=@d7, DiscountAmt=@d8, PreviousDue=@d9, Fine=@d10, GrandTotal=@d11, TotalPaid=@d12, ModeOfPayment=@d13, PaymentModeDetails=@d14, PaymentDue=@d16 where CFP_ID= '" & txtCFPId.Text & "'"
cmd = New SqlCommand(cb)
cmd.Connection = con
cmd.Parameters.AddWithValue("@d1", Val(txtCFPId.Text))
cmd.Parameters.AddWithValue("@d2", txtFeePaymentID.Text)
cmd.Parameters.AddWithValue("@d3", txtAdmissionNo.Text)
cmd.Parameters.AddWithValue("@d4", txtSession.Text)
cmd.Parameters.AddWithValue("@d6", txtCourseFee.Text)
cmd.Parameters.AddWithValue("@d7", txtDiscountPer.Text)
cmd.Parameters.AddWithValue("@d8", txtDiscount.Text)
cmd.Parameters.AddWithValue("@d9", txtPreviousDue.Text)
cmd.Parameters.AddWithValue("@d10", txtFine.Text)
cmd.Parameters.AddWithValue("@d11", txtGrandTotal.Text)
cmd.Parameters.AddWithValue("@d12", txtTotalPaid.Text)
cmd.Parameters.AddWithValue("@d13", cmbPaymentMode.Text)
cmd.Parameters.AddWithValue("@d14", txtPaymentModeDetails.Text)
cmd.Parameters.AddWithValue("@d16", txtBalance.Text)
cmd.ExecuteNonQuery()
con.Close()
con = New SqlConnection(cs)
con.Open()
Dim cq As String = "delete from CourseFeePayment_Join where C_PaymentID= " & txtCFPId.Text & ""
cmd = New SqlCommand(cq)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
con.Open()
Dim cb1 As String = "insert into CourseFeePayment_Join(C_PaymentID,Month, FeeName, Fee) VALUES (" & txtCFPId.Text & ",@d1,@d2,@d3)"
cmd = New SqlCommand(cb1)
cmd.Connection = con
' Prepare command for repeated execution
cmd.Prepare()
' Data to be inserted
For Each row As DataGridViewRow In dgw.Rows
If Not row.IsNewRow Then
cmd.Parameters.AddWithValue("@d1", row.Cells(0).Value)
cmd.Parameters.AddWithValue("@d2", row.Cells(1).Value)
cmd.Parameters.AddWithValue("@d3", Val(row.Cells(2).Value))
cmd.ExecuteNonQuery()
cmd.Parameters.Clear()
End If