日期:2014-05-17  浏览次数:21016 次

关于ADODB.Recordset 中open方法使用
using System;                                                   
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Data.OracleClient;
using System.Configuration;
using System.Data.Common;
using ADODB;

namespace DLFlo.DBUtility
{
public static object GetSingle(string SQLString, ADODB.Connection objCn)
        {
            try
            {
                ADODB.Recordset rs = new ADODB.Recordset();
                rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
                rs.CursorType = ADODB.CursorTypeEnum.adOpenStatic;
                rs.LockType = ADODB.LockTypeEnum.adLockBatchOptimistic;
                rs.Open(SQLString, objCn);//报这里的open方法没有采用2个参数的重载
                rs.ActiveConnection = null;
                object obj = rs.Fields[0].OriginalValue;
                rs.Close();
                rs = null;

                return obj;
            }
            catch (System.SystemException e)
            {
                throw e;
            }
        }
}

------解决方案--------------------
Open([Source],[ActiveConnection],[CursorType],[LockType],[Options])
有5个参数,你只给2个肯定不行啊

------解决方案--------------------
为什么不用ado.net?这个更好用
------解决方案--------------------
后面还有三个参数,你可以看看这些参数说明
http://blog.csdn.net/ivbapplication/article/details/2996214