Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2010
    Posts
    26

    Answered: Update with parameters Not Working

    Hi all
    I'm trying to Update a pervasive DB with the following Query. It looks like the parameters aren't working.
    I don't receive any errors, it just doesn't update.

    Code:
     Public Sub SaveDB()
            Dim wbcon As New OdbcConnection
            Dim cmd As New OdbcCommand
            Dim msk As String = "REV111"
            Dim field As String = "RevNo"
            Dim Link As String = "0D0BBEA6ECC24AAF8CDB49F94A1A0B6E"
            Dim UpdateString As String = "UPDATE WB_MASK SET MASK=? WHERE Field_Name=? AND LI_Guid=?"
            Try
                wbcon = Main.CWdb
                wbcon.Open()
                With cmd
                    .Parameters.Add("@Mask", System.Data.Odbc.OdbcType.VarChar, 10).Value = msk
                    .Parameters.Add("@Field", System.Data.Odbc.OdbcType.VarChar, 10).Value = field
                    .Parameters.Add("@Linke", System.Data.Odbc.OdbcType.VarChar, 50).Value = Link
                    .CommandType = CommandType.Text
                    .CommandText = UpdateString
                    .Connection = wbcon
                    .ExecuteNonQuery()
                End With
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
            wbcon.Close()
        End Sub
    But if I remove the parameters and replace the query with the following it works.
    UpdateString = "UPDATE OELI_WB_MASK SET MASK='REV-123' WHERE Field_Name='RevNo' AND OELI_Guid='0D0BBEA6ECC24AAF8CDB49F94A1A0B6E'"

    Thanks in advance
    Last edited by Viper5646; 09-08-15 at 19:01.
    VIPER

  2. Best Answer
    Posted by mirtheil

    "Was it a typo or do you have two different values for the MASK field? In your code, msk is set to "REV111" but in the hard coded query, it's "REV-123". They are different values and have different formats (REV111 vs REV-123).
    Your code looks fine beyond the difference in values."


  3. #2
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    Was it a typo or do you have two different values for the MASK field? In your code, msk is set to "REV111" but in the hard coded query, it's "REV-123". They are different values and have different formats (REV111 vs REV-123).
    Your code looks fine beyond the difference in values.
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  4. #3
    Join Date
    Mar 2010
    Posts
    26
    Thank's mirtheil
    It's not a typo it's just that the Mask field is suppose to take any string value. So I did tried with various strings and before I posted this code that was what I had.
    Now It's working and no changes were made.
    Last edited by Viper5646; 09-09-15 at 22:58.
    VIPER

Posting Permissions

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