MySQL Forums
Forum List  »  Connector/ODBC

Changes to using Parameter in ODBC
Posted by: None Of Your
Date: April 15, 2015 12:27PM

Hi,

I updated from ODBC Connector 5.2.4 to the latest 5.3.4 and now none of my parametised SQL works;

For example this works fine under 5.2.4 but fails on any connector version after 5.2.4 ;

Public Function Update(WhereClause As String) As Integer
Dim Ins As String = "UPDATE " + Table + " SET "
Dim i As Integer
Dim dbState As Integer

dbState = dbConnect.State
'
' Build update string
'
For i = 0 To Fields.GetUpperBound(0)
If Fields(i).Auto = False And Fields(i).Updated = True Then
Ins += Fields(i).FieldName + "=?,"
End If
Next

Ins = Ins.Substring(0, Ins.Length - 1) + " " + WhereClause

dbCommand.CommandText = Ins
'
' Add parameter values
'
For i = 0 To Fields.GetUpperBound(0)
If Fields(i).Auto = False And Fields(i).Updated = True Then
dbCommand.Parameters.AddWithValue("@" + Fields(i).FieldName, Fields(i).Value)
End If
Next
'
' Execute
'
If dbConnect.State = ConnectionState.Closed Then
dbConnect.Open()
End If

Update = dbCommand.ExecuteNonQuery

If dbState = ConnectionState.Closed Then
dbConnect.Close()
End If

Me.Reset()
End Function

Has the parameter changed, the string built looks like "UPDATE <table> SET <field1>=?,<field2>=?" etc where fieldx is an actual field name.

Has something changed?

Options: ReplyQuote


Subject
Written By
Posted
Changes to using Parameter in ODBC
April 15, 2015 12:27PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.