Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Currently I'm develop a system using VB.NET. I have the following query for UPDATE. This query is work when I run in SQL Developer

SQL
UPDATE CCS2_TBL_INSPECTION_STANDARD SET CCSEQREVITEM = :CCSEQREVITEM, 
CCSREVEFFECTIVEDATE = TO_DATE(:CCSREVEFFECTIVEDATE,'DD/MM/YYYY') WHERE CCSEQID 
= :CCSEQID



But when I try applied this query in VB.net, its not work. Actually the flow for this update function is work but when I update the data, it is not working. For example, I want update name from 'Ali' to 'Abu', when I click the update button, there popup windows says that "Update success" but the name is not change to 'Abu', it still 'Ali'. There no error when I execute. Anyone know?

What I have tried:

VB
Protected Sub editInspectionRev(eqid As String)

    Dim xSQL As New System.Text.StringBuilder
    xSQL.AppendLine("UPDATE CCS2_TBL_INSPECTION_STANDARD")
    xSQL.AppendLine("SET")
    xSQL.AppendLine("CCSEQREVITEM = :CCSEQREVITEM, CCSREVEFFECTIVEDATE = TO_DATE(:CCSREVEFFECTIVEDATE,'DD/MM/YYYY')")
    xSQL.AppendLine("WHERE CCSEQID = :CCSEQID")

    Using cn As New OracleConnection(ConString)
        cn.Open()
        Dim cmd As New OracleCommand(xSQL.ToString, cn)
        cmd.Connection = cn


        cmd.Parameters.Add(":CCSEQREVITEM", txtRevContent.Text)
        cmd.Parameters.Add(":CCSREVEFFECTIVEDATE", txtRevEffDate.Text)


        cmd.Parameters.Add(":CCSEQID", eqid)

        cmd.ExecuteNonQuery()
        cn.Close()

    End Using
    success3.Visible = True
    DisplayRevisionDetails()

End Sub
Posted
Updated 3-May-18 21:25pm
v2

1 solution

Replace this:
VB.NET
Using cn As New OracleConnection(ConString)

with:
VB.NET
Using cn As New OracleConnection(ConString) _
	With {.CommandType = CommandType.Text, .BindByName = True}


This should help in recognizing parameters by their names.

More details, you'll find here: Gotcha #1161: Using Named Parameters with Oracle ODP.NET[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900