-
Update Error
Hi,
I am calling this function when a button is CLICKED and received the error;
The name "The" is not permitted in this context. Valid expression are constants, constants expression, and (in some contexts) variables. Column names are not permitted.
Unclosed quotation mark after the character string 'True)'.
The function is as follows;
Code:
Private Sub Save()
Dim conn As SqlConnection = GetDbConnection()
Dim query As String
Dim cmd As New SqlCommand
Dim irow As Integer
For irow = 0 To DgvPracExcl.Rows.Count - 1
Try
query = "INSERT INTO dbo.TblPracExclude (prac_no, prac_name, prac_status, prac_enabled) VALUES (" & _
DgvPracExcl.Rows(irow).Cells(0).Value & ", " & _
DgvPracExcl.Rows(irow).Cells(1).Value & ", " & _
DgvPracExcl.Rows(irow).Cells(2).Value & ", '" & _
DgvPracExcl.Rows(irow).Cells(3).Value & ")"
cmd = New SqlCommand(query, conn)
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "VeriSIS")
End Try
Next irow
End Sub
Any help please..
Thanks
-
Re: Update Error
What types are prac_no, prac_name, prac_status, prac_enabled? Strings will need to be started and ended with a ' . You kind of have one here:
Code:
DgvPracExcl.Rows(irow).Cells(2).Value & ", '" & _
but it doesn't appear to be closed.
-
Re: Update Error
Yes if the quotes are required for this field then you need to add another one to close it as show here or if they are not required then you should remove the one shown in the post above
Code:
DgvPracExcl.Rows(irow).Cells(3).Value & "')"
Of course the error message shows the value as True so I am wondering if this is a boolean field? single quotes are only used around text fields and dates