G
Guest
I get this error when trying to use a paramter on a dynamic sql statement.
What am I doing wrong.
Exception Details: System.Data.OracleClient.OracleException: ORA-01036:
illegal variable name/number
Here is the code:
Dim strSQL As String
Dim intMyVal as integar = 5
strSQL = "SELECT * FROM TABLE WHERE(NUMBERCOL = @VAL)"
Dim oOracleConn As New OracleConnection(connstring)
If oOracleConn.State = ConnectionState.Closed Then
oOracleConn.Open()
End If
Dim cmdRoles As New OracleCommand(strSQL, oOracleConn)
cmdRoles.CommandType = CommandType.Text
Dim prm1 As New OracleParameter("@VAL", OracleType.Number)
prm1.Size = 3
prm1.Scale = 0
prm1.Value = intMyVal
prm1.Direction = ParameterDirection.Input
prm1.SourceVersion = DataRowVersion.Current
cmdRoles.Parameters.Add(prm1)
Dim dsNames As New DataSet
Dim da As New OracleDataAdapter(cmdRoles)
da.Fill(dsRoles) <-- fails here. when executing the command.
I do not how to make this work. The oracle column is NUMBER SIZE 3, SCALE 0.
Any help would be appreciated.
What am I doing wrong.
Exception Details: System.Data.OracleClient.OracleException: ORA-01036:
illegal variable name/number
Here is the code:
Dim strSQL As String
Dim intMyVal as integar = 5
strSQL = "SELECT * FROM TABLE WHERE(NUMBERCOL = @VAL)"
Dim oOracleConn As New OracleConnection(connstring)
If oOracleConn.State = ConnectionState.Closed Then
oOracleConn.Open()
End If
Dim cmdRoles As New OracleCommand(strSQL, oOracleConn)
cmdRoles.CommandType = CommandType.Text
Dim prm1 As New OracleParameter("@VAL", OracleType.Number)
prm1.Size = 3
prm1.Scale = 0
prm1.Value = intMyVal
prm1.Direction = ParameterDirection.Input
prm1.SourceVersion = DataRowVersion.Current
cmdRoles.Parameters.Add(prm1)
Dim dsNames As New DataSet
Dim da As New OracleDataAdapter(cmdRoles)
da.Fill(dsRoles) <-- fails here. when executing the command.
I do not how to make this work. The oracle column is NUMBER SIZE 3, SCALE 0.
Any help would be appreciated.