Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Iam developing a vb.NET application and trying to insert and update a database table. Will the below update query work? If I set BindByName = True will .NET consider null and SYSDATE as parameters as well? P.S this is shortened query and the actual query is a bit complex and so wanted some confirmation before i try it out


cmd.Parameters.Clear() 
cmd.CommandText = "UPDATE TBL_xxx_xxx SET NEXT=null, ACTIONDATE=SYSDATE, comments=:pcomments, STATUS=11 WHERE ACTIONDATE IS NULL AND WFID=:pwid AND ACTIONBY=:pactionby" 
cmd.CommandType = CommandType.Text 
cmd.BindByName = True

                    cmd.Parameters.Add(New OracleParameter(":pcomments", OracleDbType.Varchar2)).Value = somevalue
                    cmd.Parameters.Add(New OracleParameter(":pwid", OracleDbType.Int64)).Value = somevalue
                    cmd.Parameters.Add(New OracleParameter(":pactionby", OracleDbType.Varchar2)).Value = somevalue

                    cmd.ExecuteQuery()


What I have tried:

Nothing so far..... I wanted some understanding of BindByName before implementing
Posted
Updated 21-Mar-18 6:09am

1 solution

As the documentation (BindByName[^]) states:
Quote:

6.2.4.5 BindByName



This property specifies the binding method in the collection.

Declaration



C#
// C#
public bool BindByName {get; set;}

Property Value



Returns true if the parameters are bound by name; returns false if the parameters are bound by position.

Remarks



Default = false.
 
Share this answer
 
v2
Comments
Member 13734676 21-Mar-18 12:22pm    
Hi Maciej, Thanks for your reply.

What happens to the NEXT=null, ACTIONDATE=SYSDATE? Will they work as normal update query
Maciej Los 21-Mar-18 12:51pm    
The best way to find out is to execute your code ;)
In other words, it should work as expected.
Member 13734676 22-Mar-18 1:15am    
:) .....yes will try it out with a small query before my actual query which is a bit complex

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