以编程方式生成 ADODB 记录集
我正在尝试在 .Net 中以编程方式生成 ADO RecordSet。这将传递到 VB6 中的现有遗留代码,该代码已经需要 ADO RecordSet,我不想更改现有代码。
我成功地在
ADODB.Recordset rs = new Recordset();
rs.Fields.Append("Height", DataTypeEnum.adInteger, 4, FieldAttributeEnum.adFldMayBeNull, null);
VB6 中的新 RecordSet 中定义字段,在不带任何参数的情况下调用 RecordSet 上的 Open 后,我可以添加记录:
rs.Open
当我尝试使用 .net 代码调用 AddNew 时,它告诉我记录集必须打开,并且我可以' t 调用 open 因为它需要以下参数:
void Open(object Source, object ActiveConnection, CursorTypeEnum CursorType, LockTypeEnum LockType, int Options);
但我正在尝试以编程方式加载 RecordSet,并且没有任何活动连接或其他数据源。
我缺少什么? 有更好的办法吗?
I am attempting to generate an ADO RecordSet programmatically within .Net. This will be passed on to existing legacy code in VB6 which is already expecting a ADO RecordSet, I do not wish to change the existing code.
I was successful in defining fields within a new RecordSet
ADODB.Recordset rs = new Recordset();
rs.Fields.Append("Height", DataTypeEnum.adInteger, 4, FieldAttributeEnum.adFldMayBeNull, null);
within VB6 I can add records after calling Open on the RecordSet with no parameters:
rs.Open
when I try to call AddNew with in .net code it tells me the recordset must be open, and I can't call open because it is expecting the following parameters:
void Open(object Source, object ActiveConnection, CursorTypeEnum CursorType, LockTypeEnum LockType, int Options);
but I am attempting to load the RecordSet programmatically and do not have any active connection or other datasource.
What am I missing?
Is there a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些参数在 ADODB.Recordset.Open< 中都是可选的/a> 方法。尝试显式传递文档。有一个参数,
Source
,没有列出明确的默认值。我想默认值是Nothing
。 编辑我猜错了,显然是System.Type.Missing
所以解决方案是:
Those parameters are all optional in the ADODB.Recordset.Open method. Try explicitly passing the default values as specified in the documentation. There is one parameter,
Source
, with no explicit default listed. I imagine the default isNothing
. EDIT I guessed wrong, apparently it isSystem.Type.Missing
So the solution is: