且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取结果集或 ADO 记录集中行数的简单方法

更新时间:2023-02-06 09:46:41

添加对Microsoft ActiveX 数据对象"库的引用.然后,您将拥有 COM 互操作类型定义以在 C# 中使用 ADO.

Add a reference to "Microsoft ActiveX Data Objects" Library. Then you will have the COM interop type definitions to work with ADO in C#.

使用 C# 脚本:

public void Main()
{
    ADODB.Recordset result = (ADODB.Recordset) Dts.Variables["result"].Value;
    int rowCount = result.RecordCount;

    Dts.TaskResult = (int)ScriptResults.Success;
}

如何添加引用 -

在此处编辑脚本并添加引用(菜单项目)步骤 - http://support.microsoft.com/kb/308611/en-us.然后,不要忘记保存.单击全部保存"以保存添加引用!

Edit the script and add a reference (menu project) Steps here - http://support.microsoft.com/kb/308611/en-us. Then, don't forget to save afterwards. Click Save All to save adding the reference!

ctrl + s 只会保存您的代码.要全部保存,请使用 ctrl+shift+s.哈哈 !太不直观了!

ctrl + s will only save your codes. To do save all, use ctrl+shift+s. LOL ! So unintuitive !