开发者

Adding Oracle parameter in an If statement not working

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜