开发者

Adding Oracle parameter in an If statement not working

开发者 https://www.devze.com 2023-03-07 14:11 出处:网络
This question branches off of my last question located here I can now add multiple parameters to my query but my next issue is that I am trying to add my parameter based on the check开发者_运维技巧e

This question branches off of my last question located here

I can now add multiple parameters to my query but my next issue is that I am trying to add my parameter based on the check开发者_运维技巧ed status of my checkbox

Here's my code

OracleConn.Open()
OracleCommand = OracleConn.CreateCommand()
OracleCommand.BindByName = True
OracleCommand.CommandText = "UPDATE db SET column1 = :param1 WHERE column2 = :param2"
OracleCommand.CommandType = CommandType.Text
OracleCommand.Parameters.Add(New OracleParameter("param1", "1234"))

If cbCheckbox1.Checked = True Then
    OracleCommand.Parameters.Add(New OracleParameter("param2", "Y"))
Else
    OracleCommand.Parameters.Add(New OracleParameter("param2", "N"))
End If

OracleCommand.ExecuteNonQuery()

It doesn't error but it doesn't update the database either

If I take the If statement out and only have one parameter in like this

OracleCommand.Parameters.Add(New OracleParameter("param2", "Y"))

Then it works fine

Is there something i'm doing wrong?

Any ideas?


I solved this by wrapping my checkbox databind in a If Not Page.IsPostBack and that fixed the problem

0

精彩评论

暂无评论...
验证码 换一张
取 消