Reputation: 408
I work with VB.NET (Windows Forms) and database in AS400 iSeries. I wont to make an Update in one table. I have this code:
query.Append("Update CLAIMSTATE ")
query.Append("SET CST_CODE = @cst_code, ")
query.Append("CST_LABEL = @cst_label, ")
query.Append("CST_POINTS = @cst_points ")
query.Append("WHERE CST_ID = @cst_id ")
Dim command As New OdbcCommand(query.ToString(), con)
command.Parameters.Add("@cst_id", OdbcType.BigInt).Value = row.Cells(0).Value
command.Parameters.Add("@cst_code", OdbcType.Char).Value = row.Cells(1).Value & ""
command.Parameters.Add("@cst_label", OdbcType.NVarChar).Value = row.Cells(2).Value & ""
command.Parameters.Add("@cst_points", OdbcType.Decimal).Value = row.Cells(3).Value
command.ExecuteNonQuery()
In this case I obtain this error: ERROR [42000] [IBM][System i Access ODBC-Treiber][DB2 fur i5/OS]SQL0113 - Name @CST_CODE not allowed.
Can anybody help me?
Thank's in advance.
Upvotes: 0
Views: 3035
Reputation: 41148
OdbcCommand
doesn't support named parameters.
Dim command As OdbcCommand = con.CreateCommand()
command.CommandText = "UPDATE CLAIMSTATE " & _
"SET CST_CODE = ?, CST_LABEL = ?, CST_POINTS = ? WHERE CST_ID = ?"
command.Parameters.Add("@cst_code", OdbcType.Char).Value = row.Cells(1).Value & ""
command.Parameters.Add("@cst_label", OdbcType.NVarChar).Value = row.Cells(2).Value & ""
command.Parameters.Add("@cst_points", OdbcType.Decimal).Value = row.Cells(3).Value
command.Parameters.Add("@cst_id", OdbcType.BigInt).Value = row.Cells(0).Value
command.ExecuteNonQuery()
Upvotes: 4