Hallo,
I am working with VB.net 2005, what am trying to do is insert fields into a table in Sql database.
The table name is TblQuarPay
The following code works perfectly well but it doesn't populate the field ToPay in the database. Quoting Error encountered can't change varchar to numeric.
ToPay is a checkbox in the datagrid and it's always set to true i.e., ThreeState = True.
I would like to load either Yes or No to the database on the field column ToPay.
The specific line of code for the checkbox is;
DgvToPay.Rows(irow).Cells(3).Value & "', '" & _
Please review the code and any assistance will be highly appreciated
Dim irow As Integer
For irow = 0 To DgvToPay.Rows.Count - 1
Try
query = "INSERT INTO gprdsql.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 & "', '" & _
DgvToPay.Rows(irow).Cells(3).Value & "', '" & _
DgvToPay.Rows(irow).Cells(4).Value & "')"
cmd = New SqlCommand(query, conn)
cmd.ExecuteNonQuery()
Catch ex As Exception
End Try
Next irow
Thanks for any help given
I am working with VB.net 2005, what am trying to do is insert fields into a table in Sql database.
The table name is TblQuarPay
The following code works perfectly well but it doesn't populate the field ToPay in the database. Quoting Error encountered can't change varchar to numeric.
ToPay is a checkbox in the datagrid and it's always set to true i.e., ThreeState = True.
I would like to load either Yes or No to the database on the field column ToPay.
The specific line of code for the checkbox is;
DgvToPay.Rows(irow).Cells(3).Value & "', '" & _
Please review the code and any assistance will be highly appreciated
Dim irow As Integer
For irow = 0 To DgvToPay.Rows.Count - 1
Try
query = "INSERT INTO gprdsql.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 & "', '" & _
DgvToPay.Rows(irow).Cells(3).Value & "', '" & _
DgvToPay.Rows(irow).Cells(4).Value & "')"
cmd = New SqlCommand(query, conn)
cmd.ExecuteNonQuery()
Catch ex As Exception
End Try
Next irow
Thanks for any help given