Пример #1
0
        /// <summary>
        /// Inits the recordset.
        /// </summary>
        protected virtual void InitRecordset()
        {
            if (Recordset.Opened)
            {
                RecordSource     = Recordset.SqlQuery;
                ConnectionString = Recordset.ConnectionString;
                //AIS: apparently unnecessary ReBind() invocation for DAO
                //ReBind();
                BindDataSet();
            }
            else if (!(string.IsNullOrEmpty(ConnectionString) || string.IsNullOrEmpty(_FactoryName) || string.IsNullOrEmpty(_RecordSource)))
            {
                Recordset.ProviderFactory = AdoFactoryManager.GetFactory(_FactoryName);
                Recordset.DatabaseType    = AdoFactoryManager.GetFactoryDbType(_FactoryName);


                Recordset.ConnectionString = ConnectionString;
                CommandType cmdtype = Recordset.getCommandType(_RecordSource);
                _QueryType = _QueryType == cmdtype ? _QueryType : cmdtype;
                if (Recordset.ProviderFactory != null)
                {
                    DbCommand command = Recordset.CreateCommand(_RecordSource, _QueryType);
                    _QueryType             = command.CommandType;
                    command.CommandTimeout = _QueryTimeout;
                    Recordset.Source       = command;
                }
            }
            Recordset.AfterMove  += new EventHandler(Recordset_onAfterMove);
            Recordset.AfterQuery += new EventHandler(Recordset_onAfterQuery);
        }
Пример #2
0
        public static object Deserialize(BinaryReader binaryReader, ISurrogateContext context)
        {
            DbConnection conn = null;

            if (context.DependencyCount > 0)
            {
                conn = context.Dependencies[0] as DbConnection;
            }
            var    hasSource = binaryReader.ReadBoolean();
            string source    = "";

            if (hasSource)
            {
                source = binaryReader.ReadString();
            }
            BinaryFormatter    bFormat = new BinaryFormatter();
            ADORecordSetHelper rs      = (ADORecordSetHelper)bFormat.Deserialize(binaryReader.BaseStream);

            rs.ProviderFactory  = AdoFactoryManager.GetFactory("");
            rs.ActiveConnection = conn;
            if (hasSource)
            {
                rs.Source = source;
            }
            return(rs);
        }
Пример #3
0
 /// <summary>
 /// CreateCommand
 /// </summary>
 /// <returns></returns>
 public DbCommand CreateCommand()
 {
     return((_connection != null) ? _connection.CreateCommand() : AdoFactoryManager.GetFactory().CreateCommand());
 }
Пример #4
0
        /// <summary>
        /// Creates a new Workspace object.
        /// </summary>
        /// <param name="name">The name of the new WorkspaceHelper.</param>
        /// <param name="factoryName">The name of the factory to by use by this WorkspaceHelper object (the name most exist on the configuration xml file).</param>
        /// <param name="user">The name of the new WorkspaceHelper.</param>
        /// <param name="password">The name of the new WorkspaceHelper.</param>
        /// <returns>The new WorkspaceHelper object.</returns>
        public static WorkspaceHelper CreateWorkspace(string name, string factoryName, string user, string password)
        {
            WorkspaceHelper ws = new WorkspaceHelper(name, AdoFactoryManager.GetFactory(factoryName), user, password);

            return(ws);
        }