OledbParameter Collection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Biren Prajapati

    #1

    OledbParameter Collection

    Hi All,

    If is is not possible to create an instance of OledbParameterC ollection
    class then how the OledbCommand class is creating an instance of
    OledbParameterC ollection in it's property "Parameters ".

    I tried to find the concept behind that but could not sort it out. If
    anyone find it for me, it will be a great help.

    Thanks,
    Biren.

  • Nick Hounsome

    #2
    Re: OledbParameter Collection


    "Biren Prajapati" <sendtobiren@gm ail.com> wrote in message
    news:1138620825 .276147.150390@ g43g2000cwa.goo glegroups.com.. .[color=blue]
    > Hi All,
    >
    > If is is not possible to create an instance of OledbParameterC ollection
    > class then how the OledbCommand class is creating an instance of
    > OledbParameterC ollection in it's property "Parameters ".[/color]

    It's not possible for YOU to create an instance of OledbParameterC ollection.
    It IS possible for OleDbCommand because it is in the same assembly and there
    will be constructor marked as "internal" which means "accessible to anything
    in this assembly".

    You will find this used a lot in the .NET framework.

    I suspect that the reason it is done this way is to reduce the number of
    possible breaking changes in subsequent releases however I think that in
    this case it would be quite nice to be able to easily reuse parameter
    collections and a reasonably common requirement.

    You'll just have to put them in a List<OldDbParam eter> and write a method to
    copy them.



    Comment

    • Biren Prajapati

      #3
      Re: OledbParameter Collection

      Thanks......... this may be the only reason.......or any other reason
      possible?

      Comment

      • Ignacio Machin \( .NET/ C# MVP \)

        #4
        Re: OledbParameter Collection

        Hi,


        "Biren Prajapati" <sendtobiren@gm ail.com> wrote in message
        news:1138624014 .488268.51730@g 44g2000cwa.goog legroups.com...[color=blue]
        > Thanks......... this may be the only reason.......or any other reason[/color]

        Conceptually you can't have a "loose" parameter, one that belongs to no
        command. Each parameter should belown to one Command. That's why the
        constructor is marked as internal and the only way to create it is through
        Command, at the creation time the connection between the Command and the
        parameter is established.

        I dont remember if you have a pattern name for this. but it's a fairly
        common occurence in cases like the above and you will find it all over the
        framework.



        --
        Ignacio Machin,
        ignacio.machin AT dot.state.fl.us
        Florida Department Of Transportation


        Comment

        Working...