本文介绍了ORA-01008:并非所有变量都绑定 - VB.NET Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个VB.NET函数来更新一个包含四列的表,如下所示。除了ORA-01008之外每次都失败:并非所有变量都绑定
有人可以帮忙吗?
I am writing a VB.NET function to update a table with four columns as per below. It is failing every time with the exception ORA-01008: not all variables bound
Can someone please help?
Public Sub UpdateLog(ByVal intUserID As Integer, ByVal strDesc As String, ByVal intLogID As Integer)
Dim oraConn As OracleConnection
Dim cmd As OracleCommand
Try
cmd = New OracleCommand
cmd.Parameters.Clear()
cmd.CommandText = "Insert Into Tbl_Trans_Log(UserID,TransID,TransDate,ActionDone) values (:userId,:logId,:transdate,:action)"
cmd.CommandType = CommandType.Text
cmd.BindByName = True
cmd.Parameters.Add(":userId", OracleDbType.Int64).Value = intUserID
cmd.Parameters.Add(":logId", OracleDbType.Int64).Value = intLogID
cmd.Parameters.Add(":transdate", OracleDbType.Date).Value = DateTime.Now
cmd.Parameters.Add(":action", OracleDbType.Varchar2).Value = strDesc
oraConn = New OracleConnection(ConfigurationManager.ConnectionStrings("connString").ConnectionString)
oraConn.Open()
cmd.Connection = oraConn
cmd.ExecuteNonQuery()
Catch ex As Exception
sWriteErrorLog("C:\", "log - sUpdateTransLog -> " & ex.Message)
Finally
oraConn.close()
End Try
End Sub
我尝试过:
在命令文本末尾添加分号
What I have tried:
Adding semicolons at the end of command text
推荐答案
cmd.CommandText = "Insert Into Tbl_Trans_Log(UserID, TransID, TransDate, ActionDone) values(:userId, :logId, :transdate, :action)"
cmd = New OracleCommand
cmd.Parameters.Clear()
cmd.CommandText = "Insert Into Tbl_Trans_Log(UserID,TransID,TransDate,ActionDone) values (:userId,:logId,:transdate,:action)"
cmd.CommandType = CommandType.Text
cmd.BindByName = True
cmd.Parameters.Add(New OracleParameter(":userId", OracleDbType.Int64)).Value = intUserID
cmd.Parameters.Add(New OracleParameter(":logId", OracleDbType.Int64)).Value = intLogID
cmd.Parameters.Add(New OracleParameter(":transdate", OracleDbType.Date)).Value = DateTime.Now
cmd.Parameters.Add(New OracleParameter(":action", OracleDbType.Varchar2)).Value = strDesc
oraConn = New OracleConnection(ConfigurationManager.ConnectionStrings("xxxxxxxxx").ConnectionString)
oraConn.Open()
cmd.Connection = oraConn
cmd.ExecuteNonQuery()
这篇关于ORA-01008:并非所有变量都绑定 - VB.NET Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!