Esempio n. 1
0
        public void Connect()
        {
            if (Charset.GetCharset(_options.Charset) == null)
            {
                throw FbException.Create("Invalid character set specified");
            }

            try
            {
                _db            = ClientFactory.CreateDatabase(_options);
                _db.Charset    = Charset.GetCharset(_options.Charset);
                _db.Dialect    = _options.Dialect;
                _db.PacketSize = _options.PacketSize;

                var dpb = BuildDpb(_db, _options);

                if (string.IsNullOrEmpty(_options.UserID) && string.IsNullOrEmpty(_options.Password))
                {
                    _db.AttachWithTrustedAuth(dpb, _options.Database, _options.CryptKey);
                }
                else
                {
                    _db.Attach(dpb, _options.Database, _options.CryptKey);
                }
            }
            catch (IscException ex)
            {
                throw FbException.Create(ex);
            }
        }
Esempio n. 2
0
        public async Task Connect(AsyncWrappingCommonArgs async)
        {
            if (Charset.GetCharset(_options.Charset) == null)
            {
                throw new FbException("Invalid character set specified");
            }

            try
            {
                _db = await ClientFactory.CreateDatabase(_options, async).ConfigureAwait(false);

                _db.Charset    = Charset.GetCharset(_options.Charset);
                _db.Dialect    = _options.Dialect;
                _db.PacketSize = _options.PacketSize;

                var dpb = BuildDpb(_db, _options);

                if (string.IsNullOrEmpty(_options.UserID) && string.IsNullOrEmpty(_options.Password))
                {
                    await _db.AttachWithTrustedAuth(dpb, _options.DataSource, _options.Port, _options.Database, _options.CryptKey, async).ConfigureAwait(false);
                }
                else
                {
                    await _db.Attach(dpb, _options.DataSource, _options.Port, _options.Database, _options.CryptKey, async).ConfigureAwait(false);
                }
            }
            catch (IscException ex)
            {
                throw new FbException(ex.Message, ex);
            }
        }