Update Error
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Update Error

  1. #1
    Join Date
    Feb 2009

    Update Error


    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;

    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
                    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)
                Catch ex As Exception
                    MsgBox(ex.Message, MsgBoxStyle.Information, "VeriSIS")
                End Try
            Next irow
        End Sub
    Any help please..


  2. #2
    Join Date
    Aug 2009
    NW USA

    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:
     DgvPracExcl.Rows(irow).Cells(2).Value & ", '" & _
    but it doesn't appear to be closed.

  3. #3
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    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
    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
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

HTML5 Development Center