none
Using VB2013 net 4.0 and Oracle DataAccess 2.121.2.0 Problem : add parameters to a OracleCommand RRS feed

  • Question

  •  Hi  I'ts a new experiance to use Oracle DB in .net environment.

    My code after i have opened a connection to Oracle Db.

        Dim GO As OracleCommand = New OracleCommand("Select One,Next from Fig where Five = :Five")

           GO.Connection = OraCon
                GO.CommandType = CommandType.Text

         GO.Parameters.Add(New OracleParameter With {.ParameterName = ":Five", .Value = '5', .OracleDbType = OracleDbType.Char})

    Using RunGo As OracleDataReader = GO.ExecuteReader

          While RunGo.Read

           Dim Client =  RunGo.Item("Next"))

         end while

          end using 

    The parameter is not passed. It works when i do not ad parameter.

    Thanks

    Regards BLIS



    • Edited by BLIS Monday, October 19, 2015 11:36 AM
    • Moved by Weiwei Cai Tuesday, October 20, 2015 5:55 AM ado.net related.
    Monday, October 19, 2015 11:34 AM

Answers

  • Thank you.

    After testing and advice from colleagues I have a solution that works.

    I use : both in the parameter when it’s created and  used in the command string.

    This is the code that worked in my environment.

                Dim MK = 5 'Integer

                Dim GO As OracleCommand = New OracleCommand("Select One,Next from Fig where Five = :Five",OraCon)

               

                GO .Parameters.Add(New Oracle.DataAccess.Client.OracleParameter() _

                With _

                {.ParameterName = ":Five", _

                             .OracleDbType = Oracle.DataAccess.Client.OracleDbType.Single, _

                             .Direction = ParameterDirection.Input, _

                                        .Value = MK})

                            Using RunGo As Oracle.DataAccess.Client.OracleDataReader = GO .ExecuteReader

                            While RunGo.Read = True

                                                    Dim One =  RunGo.Item("One"))

                                                    Dim Next =  RunGo.Item("Next"))

                                        End While

                            End Using

    Regards


    Bo

    • Marked as answer by BLIS Friday, October 23, 2015 9:04 AM
    Friday, October 23, 2015 9:04 AM

All replies

  • Hi BLIS,

    This forum is discuss Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    Since your problem is more related to ADO.NET, I will help you move this thread to ADO.NET Managed Providers forum for a better help.

    Best Regards,
    Weiwei

    Tuesday, October 20, 2015 5:55 AM
  • Thank you Weiwei

    Bo

    Tuesday, October 20, 2015 5:57 AM
  • It is not necessary to add the colon(:) in the OracleParameter like in the query statement, change “{.ParameterName = ":Five",” to “{.ParameterName = "Five",”.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 21, 2015 1:41 AM
    Moderator
  • Thank you.

    After testing and advice from colleagues I have a solution that works.

    I use : both in the parameter when it’s created and  used in the command string.

    This is the code that worked in my environment.

                Dim MK = 5 'Integer

                Dim GO As OracleCommand = New OracleCommand("Select One,Next from Fig where Five = :Five",OraCon)

               

                GO .Parameters.Add(New Oracle.DataAccess.Client.OracleParameter() _

                With _

                {.ParameterName = ":Five", _

                             .OracleDbType = Oracle.DataAccess.Client.OracleDbType.Single, _

                             .Direction = ParameterDirection.Input, _

                                        .Value = MK})

                            Using RunGo As Oracle.DataAccess.Client.OracleDataReader = GO .ExecuteReader

                            While RunGo.Read = True

                                                    Dim One =  RunGo.Item("One"))

                                                    Dim Next =  RunGo.Item("Next"))

                                        End While

                            End Using

    Regards


    Bo

    • Marked as answer by BLIS Friday, October 23, 2015 9:04 AM
    Friday, October 23, 2015 9:04 AM