dr223
February 23rd, 2009, 08:21 AM
Hallo,
I am working with SQL and Vb.net. When I run the following function (shown below) an error is highlighted "Error converting varchar to numeric". Whats wrong with the coding that triggers the error..
Dim query As String
Dim cmd As New SqlCommand
Dim irow As Integer
For irow = 0 To DgvToPay.Rows.Count - 1
If DgvToPay.Rows(irow).Cells(3).Value = True Then
Try
query = "INSERT INTO xyz.TblQuarPay (prac_no, prac_eid, num_pats, ToPay,
AmounttobePaid) VALUES ('" & _
DgvToPay.Rows(irow).Cells(0).Value & "', '" & _
DgvToPay.Rows(irow).Cells(1).Value & "', '" & _
DgvToPay.Rows(irow).Cells(2).Value & "', '" & _
"Yes" & "', '" & _
DgvToPay.Rows(irow).Cells(4).Value & "')"
cmd = New SqlCommand(query, conn)
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Payment System")
End Try
End If
Next irow
End Sub
Thanks
I am working with SQL and Vb.net. When I run the following function (shown below) an error is highlighted "Error converting varchar to numeric". Whats wrong with the coding that triggers the error..
Dim query As String
Dim cmd As New SqlCommand
Dim irow As Integer
For irow = 0 To DgvToPay.Rows.Count - 1
If DgvToPay.Rows(irow).Cells(3).Value = True Then
Try
query = "INSERT INTO xyz.TblQuarPay (prac_no, prac_eid, num_pats, ToPay,
AmounttobePaid) VALUES ('" & _
DgvToPay.Rows(irow).Cells(0).Value & "', '" & _
DgvToPay.Rows(irow).Cells(1).Value & "', '" & _
DgvToPay.Rows(irow).Cells(2).Value & "', '" & _
"Yes" & "', '" & _
DgvToPay.Rows(irow).Cells(4).Value & "')"
cmd = New SqlCommand(query, conn)
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Payment System")
End Try
End If
Next irow
End Sub
Thanks