Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Connectionless recordset error

Connectionless recordset error

Scheduled Pinned Locked Moved Database
csharphelpc++question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adam Gritt
    wrote on last edited by
    #1

    In trying to create a recordset I keep getting an error when I open it under C#. I would use ADO.NET, but for backwards compliance with the application it talks too, I need ADO 2.6. Below is a snippet of the code I am using. If anyone has input as to what the problem may be, please let me know. [code] ADODB.Recordset rs = new ADODB.Recordset; Object obj1 = null; Object obj2 = null; rs.Fields.Append( "Name", adVarChar, 32, adFldMayBeNull, null ); rs.CursorLocation = adUseClient; rs.Open( obj1, obj2, adOpenForwardOnly, adLockReadOnly, -1 ); [/code] This code causes a COMException under C# that says: "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another." The same code works fine under regular c++ and VB6. Does anyone have any input to this?

    M 1 Reply Last reply
    0
    • A Adam Gritt

      In trying to create a recordset I keep getting an error when I open it under C#. I would use ADO.NET, but for backwards compliance with the application it talks too, I need ADO 2.6. Below is a snippet of the code I am using. If anyone has input as to what the problem may be, please let me know. [code] ADODB.Recordset rs = new ADODB.Recordset; Object obj1 = null; Object obj2 = null; rs.Fields.Append( "Name", adVarChar, 32, adFldMayBeNull, null ); rs.CursorLocation = adUseClient; rs.Open( obj1, obj2, adOpenForwardOnly, adLockReadOnly, -1 ); [/code] This code causes a COMException under C# that says: "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another." The same code works fine under regular c++ and VB6. Does anyone have any input to this?

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      If you need to omit an optional parameter in a COM call using C#, you should use System.Reflection.Missing.Value.

      ADODB.Recordset rs = new ADODB.Recordset();

      rs.Fields.Append(
      "Name",
      DataTypeEnum.adVarChar,
      32,
      FieldAttributeEnum.adFldMayBeNull,
      null );

      rs.CursorLocation = CursorLocationEnum.adUseClient;

      rs.Open(
      Missing.Value,
      Missing.Value,
      CursorTypeEnum.adOpenForwardOnly,
      LockTypeEnum.adLockReadOnly,
      -1 );

      Stability. What an interesting concept. -- Chris Maunder

      A 1 Reply Last reply
      0
      • M Mike Dimmick

        If you need to omit an optional parameter in a COM call using C#, you should use System.Reflection.Missing.Value.

        ADODB.Recordset rs = new ADODB.Recordset();

        rs.Fields.Append(
        "Name",
        DataTypeEnum.adVarChar,
        32,
        FieldAttributeEnum.adFldMayBeNull,
        null );

        rs.CursorLocation = CursorLocationEnum.adUseClient;

        rs.Open(
        Missing.Value,
        Missing.Value,
        CursorTypeEnum.adOpenForwardOnly,
        LockTypeEnum.adLockReadOnly,
        -1 );

        Stability. What an interesting concept. -- Chris Maunder

        A Offline
        A Offline
        Adam Gritt
        wrote on last edited by
        #3

        Thank you very much. I am still learning the intricisies of C# and haven't looked into the System.Reflection namespace much yet. Everything works fine now. Thanks for the help.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups