Open Unconnected ADORecordset

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brent Rogers

    #1

    Open Unconnected ADORecordset

    I am trying to open an Unconnected/Disconnected ADORecordset.

    Using VB I would use the following function call

    rs.Open()

    However C# requires a Source and Connection.
    What do I pass in?
    I have tried null, the null string, zeros, empty objects but I keep getting
    a runtime error when I try to open the Recordset

    Any help would be appreciated.
  • Frank Rizzo

    #2
    Re: Open Unconnected ADORecordset

    Brent Rogers wrote:[color=blue]
    > I am trying to open an Unconnected/Disconnected ADORecordset.
    >
    > Using VB I would use the following function call
    >
    > rs.Open()
    >
    > However C# requires a Source and Connection.
    > What do I pass in?
    > I have tried null, the null string, zeros, empty objects but I keep getting
    > a runtime error when I try to open the Recordset
    >
    > Any help would be appreciated.[/color]

    add the Interop goo to the using statement. Then

    rs.Open(Type.Mi ssing, Type.Missing);

    Comment

    • Brent Rogers

      #3
      Re: Open Unconnected ADORecordset

      Frank:

      When I try that I get the error:

      The connection cannot be used to perform this operation. It is either closed
      or invalid in this context.

      "Frank Rizzo" wrote:
      [color=blue]
      > Brent Rogers wrote:[color=green]
      > > I am trying to open an Unconnected/Disconnected ADORecordset.
      > >
      > > Using VB I would use the following function call
      > >
      > > rs.Open()
      > >
      > > However C# requires a Source and Connection.
      > > What do I pass in?
      > > I have tried null, the null string, zeros, empty objects but I keep getting
      > > a runtime error when I try to open the Recordset
      > >
      > > Any help would be appreciated.[/color]
      >
      > add the Interop goo to the using statement. Then
      >
      > rs.Open(Type.Mi ssing, Type.Missing);
      >[/color]

      Comment

      • Frank Rizzo

        #4
        Re: Open Unconnected ADORecordset

        Brent Rogers wrote:[color=blue]
        > Frank:
        >
        > When I try that I get the error:
        >
        > The connection cannot be used to perform this operation. It is either closed
        > or invalid in this context.[/color]

        Then the connection is probably not assigned to the recordset.

        rs.ActiveConnec tion = whatever your connection is.
        [color=blue]
        >
        > "Frank Rizzo" wrote:
        >[color=green]
        >> Brent Rogers wrote:[color=darkred]
        >>> I am trying to open an Unconnected/Disconnected ADORecordset.
        >>>
        >>> Using VB I would use the following function call
        >>>
        >>> rs.Open()
        >>>
        >>> However C# requires a Source and Connection.
        >>> What do I pass in?
        >>> I have tried null, the null string, zeros, empty objects but I keep getting
        >>> a runtime error when I try to open the Recordset
        >>>
        >>> Any help would be appreciated.[/color]
        >> add the Interop goo to the using statement. Then
        >>
        >> rs.Open(Type.Mi ssing, Type.Missing);
        >>[/color][/color]

        Comment

        • Brent Rogers

          #5
          Re: Open Unconnected ADORecordset

          The thing is that I dont have a connection..

          "Frank Rizzo" wrote:
          [color=blue]
          > Brent Rogers wrote:[color=green]
          > > Frank:
          > >
          > > When I try that I get the error:
          > >
          > > The connection cannot be used to perform this operation. It is either closed
          > > or invalid in this context.[/color]
          >
          > Then the connection is probably not assigned to the recordset.
          >
          > rs.ActiveConnec tion = whatever your connection is.
          >[color=green]
          > >
          > > "Frank Rizzo" wrote:
          > >[color=darkred]
          > >> Brent Rogers wrote:
          > >>> I am trying to open an Unconnected/Disconnected ADORecordset.
          > >>>
          > >>> Using VB I would use the following function call
          > >>>
          > >>> rs.Open()
          > >>>
          > >>> However C# requires a Source and Connection.
          > >>> What do I pass in?
          > >>> I have tried null, the null string, zeros, empty objects but I keep getting
          > >>> a runtime error when I try to open the Recordset
          > >>>
          > >>> Any help would be appreciated.
          > >> add the Interop goo to the using statement. Then
          > >>
          > >> rs.Open(Type.Mi ssing, Type.Missing);
          > >>[/color][/color]
          >[/color]

          Comment

          • Frank Rizzo

            #6
            Re: Open Unconnected ADORecordset

            Brent Rogers wrote:[color=blue]
            > The thing is that I dont have a connection..[/color]

            You mean, previously you saved the recordset to a file and now you're
            trying to reopen it?

            In that case, you have to pass in the name of that file.

            You are not sharing a lot of information. Kind of difficult to help.
            [color=blue]
            >
            > "Frank Rizzo" wrote:
            >[color=green]
            >> Brent Rogers wrote:[color=darkred]
            >>> Frank:
            >>>
            >>> When I try that I get the error:
            >>>
            >>> The connection cannot be used to perform this operation. It is either closed
            >>> or invalid in this context.[/color]
            >> Then the connection is probably not assigned to the recordset.
            >>
            >> rs.ActiveConnec tion = whatever your connection is.
            >>[color=darkred]
            >>> "Frank Rizzo" wrote:
            >>>
            >>>> Brent Rogers wrote:
            >>>>> I am trying to open an Unconnected/Disconnected ADORecordset.
            >>>>>
            >>>>> Using VB I would use the following function call
            >>>>>
            >>>>> rs.Open()
            >>>>>
            >>>>> However C# requires a Source and Connection.
            >>>>> What do I pass in?
            >>>>> I have tried null, the null string, zeros, empty objects but I keep getting
            >>>>> a runtime error when I try to open the Recordset
            >>>>>
            >>>>> Any help would be appreciated.
            >>>> add the Interop goo to the using statement. Then
            >>>>
            >>>> rs.Open(Type.Mi ssing, Type.Missing);
            >>>>[/color][/color][/color]

            Comment

            • Brent Rogers

              #7
              Re: Open Unconnected ADORecordset

              What I wanted was actually an 'In Memory' recordset.
              I wanted to be able to perform the same action as the VB:
              rs.Open()
              would do.

              I was able to do this with the following:
              MyRecordset.Ope n( Missing.Value
              ,Missing.Value ,ADODB.CursorTy peEnum.adOpenUn specified ,ADODB.LockType Enum.adLockUnsp ecified ,(int)ADODB.Com mandTypeEnum.ad CmdUnspecified );

              The key was setting the Options parameter to:
              (int)ADODB.Comm andTypeEnum.adC mdUnspecified
              rather than null and/or zero.



              "Frank Rizzo" wrote:
              [color=blue]
              > Brent Rogers wrote:[color=green]
              > > The thing is that I dont have a connection..[/color]
              >
              > You mean, previously you saved the recordset to a file and now you're
              > trying to reopen it?
              >
              > In that case, you have to pass in the name of that file.
              >
              > You are not sharing a lot of information. Kind of difficult to help.
              >[color=green]
              > >
              > > "Frank Rizzo" wrote:
              > >[color=darkred]
              > >> Brent Rogers wrote:
              > >>> Frank:
              > >>>
              > >>> When I try that I get the error:
              > >>>
              > >>> The connection cannot be used to perform this operation. It is either closed
              > >>> or invalid in this context.
              > >> Then the connection is probably not assigned to the recordset.
              > >>
              > >> rs.ActiveConnec tion = whatever your connection is.
              > >>
              > >>> "Frank Rizzo" wrote:
              > >>>
              > >>>> Brent Rogers wrote:
              > >>>>> I am trying to open an Unconnected/Disconnected ADORecordset.
              > >>>>>
              > >>>>> Using VB I would use the following function call
              > >>>>>
              > >>>>> rs.Open()
              > >>>>>
              > >>>>> However C# requires a Source and Connection.
              > >>>>> What do I pass in?
              > >>>>> I have tried null, the null string, zeros, empty objects but I keep getting
              > >>>>> a runtime error when I try to open the Recordset
              > >>>>>
              > >>>>> Any help would be appreciated.
              > >>>> add the Interop goo to the using statement. Then
              > >>>>
              > >>>> rs.Open(Type.Mi ssing, Type.Missing);
              > >>>>[/color][/color]
              >[/color]

              Comment

              Working...