I am using an sql command to store a command text and some parameters:
myOracleCommand = New OracleCommand
With myOracleCommand
.CommandType = CommandType.Text
.CommandText = "MY QUERY"
.Parameters.Add(New OracleParameter("Test1", OracleDbType.Varchar2, "05", ParameterDirection.Input))
.Parameters.Add(New OracleParameter("Test2", OracleDbType.Varchar2, DBNull.Value, ParameterDirection.Input))
.Parameters.Add(New OracleParameter("Test3", OracleDbType.Int32, DBNull.Value, ParameterDirection.Input))
.CommandTimeout = 60
End With
' But after running this :
ExecuteReader("T3B", myOracleCommand.CommandText.ToString, Text, myOracleCommand.Parameters)
Then I am getting this message error :
Cannot convert a value of type ' Oracle.DataAccess.Client.OracleParameterCollection ' to ' Table 1 dimension ( s) Oracle.DataAccess.Client.OracleParameter '
What should I do to fix the problem?
I believe, I know the answer for your issue. In this line
you use
myOracleCommand.Parameters, which is of typeOracleParameterCollection, wileExecuteReaderexpects array ofOracleParameter.What you need to do is convert this collection to an array and pass that array. And for that
OracleParameterCollectionhas methodCopyTo. So, it is trivialNote:
ToStringis not needed inCommandText.ToString()because command text is already a string