我在ASP.NET Gridview中添加了一个按钮列,如此,
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button ID="btnBlacklist" runat="server" CausesValidation="false" CommandName="Pass"
Text="PASS" CommandArgument ='<%# Eval("ACCOUNT_ID")%>'/>s
</ItemTemplate>
</asp:TemplateField>
</Columns>
在后面的代码中,添加了类似的触发事件,
Protected Sub gTransReport_RowCommand(sender As Object, e As GridViewCommandEventArgs)
If e.CommandName = "Pass" Then
Dim accountId As Integer = Convert.ToInt32(e.CommandArgument)
DbConn = New OleDbConnection()
Try
dbdll.ConnectDB(connString, DbConn)
If DbConn.State <> ConnectionState.Open Then
DbConn.Open()
End If
Catch ex As Exception
ClassMC.putToErrorLog("[" & Session("USER").ToString().Trim & "] " & ex.Message & ex.StackTrace)
Session("ERRORDESC") = ex.Message & " " & ex.StackTrace
Page.Response.Redirect("ZapError.aspx")
End Try
Try
Using dbCommand As New OleDbCommand("UPDATE AML_INDIVIDUAL_PERCENTAGE SET SECOND_NAME = 'PASS' WHERE ACCOUNT_ID = '@accountID'", DbConn)
dbCommand.Parameters.AddWithValue("@accountID", accountId)
dbCommand.CommandType = CommandType.Text
dbCommand.ExecuteNonQuery()
End Using
Catch ex As Exception
ClassMC.putToErrorLog("[" & Session("USER").ToString().Trim & "] " & ex.Message & ex.StackTrace)
Session("ERRORDESC") = ex.Message & " " & ex.StackTrace
Page.Response.Redirect("ZapError.aspx")
Finally
DbConn.Close()
End Try
lblBlacklist.Text = "User passed!!"
End If
End Sub
带有报告的GridView显示正常,但是当我单击PASS按钮时,会抛出ORA-01722: invalid number
错误。我的数据库架构ACCOUNT_ID
是NUMBER
。我调试了我的代码,并且不知道为什么抛出这个错误,帮助。
答案 0 :(得分:0)
不要将参数包装在像这里的撇号中那样:
WHERE ACCOUNT_ID = '@accountID'
代替:
WHERE ACCOUNT_ID = @accountID
否则字符串@accountID
将用作accountID的值,而不是数字。
更新:oracle中的afaik
WHERE ACCOUNT_ID = :accountID