示例#1
0
        public sealed override void Open(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new Exception("Invalid connection string");
            }
            try
            {
                if (IsOpened)
                {
                    return;
                }

                baseConn = new SqlCeConnection(connectionString);
                baseConn.Open();


                invalidator = new InvalidatorForSqlCe();
            }
            catch (SqlCeException ee)
            {
                throw ee;
            }
        }
示例#2
0
        public sealed override void Open(BaseLoginInfo pInfo)
        {
            //Record to base class (Vital)
            baseLoginInfo = pInfo;


            LoginInfo_SSCE          myInfo  = pInfo as LoginInfo_SSCE;
            LoginInfo_ForAllDbTypes allInfo = pInfo as LoginInfo_ForAllDbTypes;

            if ((myInfo == null) && (allInfo == null))
            {
                throw new ArgumentException("Only Support SSCE login info and AllDBTypes Info");
            }

            if (IsOpened)
            {
                return;
            }

            string myConnString = string.Empty;

            try
            {
                if (allInfo != null)
                {
                    myInfo             = new LoginInfo_SSCE();
                    myInfo.DbName      = allInfo.Database;
                    myInfo.Pwd         = allInfo.Pwd;
                    myInfo.IsEncrypted = allInfo.IsEncrypt;
                }

                OpenModeClass op = new OpenModeClass();
                op.mode = myInfo.CurOpenMode;
                switch (myInfo.CurOpenMode)
                {
                case OpenMode.ReadWrite:
                    op.modeDisplayName = "Read Write";
                    break;

                case OpenMode.ReadOnly:
                    op.modeDisplayName = "Read Only";
                    break;

                case OpenMode.Exclusive:
                    op.modeDisplayName = "Exclusive";
                    break;

                case OpenMode.SharedRead:
                    op.modeDisplayName = "Shared Read";
                    break;

                default:
                    op.modeDisplayName = "Read Write";
                    break;
                }

                if (myInfo.MaxBufferSize == 0)
                {
                    myInfo.MaxBufferSize = 1024;
                }
                if (myInfo.MaxDbSize == 0)
                {
                    myInfo.MaxDbSize = 4000;
                }

                myConnString = DbConnectionString.SSCE.GetSSCEConnectionString(
                    myInfo.DbName, myInfo.Pwd, myInfo.IsEncrypted, op, myInfo.MaxDbSize, myInfo.MaxBufferSize);


                baseConn = new SqlCeConnection(myConnString);
                baseConn.Open();

                CurDatabase = myInfo.DbName;
                CurPwd      = myInfo.Pwd;

                invalidator = new InvalidatorForSqlCe();
            }
            catch (Exception e)
            {
                throw e;
            }
        }