Connectionless recordset error
-
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?
-
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?
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
-
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
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.