Beispiel #1
0
        private bool OpenConnection(SdeConnection sdeConnection, IDataset dataset)
        {
            _errMsg = "";

            if (sdeConnection.SeConnection.handle != IntPtr.Zero)
            {
                CloseConnection(sdeConnection);
            }

            string server   = ConfigTextStream.ExtractValue(_connectionString, "server");
            string instance = ConfigTextStream.ExtractValue(_connectionString, "instance");
            string database = ConfigTextStream.ExtractValue(_connectionString, "database");
            string username = ConfigTextStream.ExtractValue(_connectionString, "usr");
            string password = ConfigTextStream.ExtractValue(_connectionString, "pwd");
            string pooling  = ConfigTextStream.ExtractValue(_connectionString, "pooling");

            if (!String.IsNullOrWhiteSpace(pooling) &&
                (pooling.ToLower() == "false" || pooling.ToLower() == "no"))
            {
                sdeConnection.Pooling = false;
            }
            else
            {
                sdeConnection.Pooling = true;
            }

            sdeConnection.Dataset = dataset;

            SE_ERROR error = new SE_ERROR();

            try
            {
                System.Int32 errCode = Wrapper10.SE_connection_create(
                    server,
                    instance,
                    database,
                    username,
                    password,
                    ref error,
                    ref sdeConnection.SeConnection);
                if (errCode != 0)
                {
                    error.sde_error = errCode;
                    _errMsg         = errCode + " " + Wrapper10.GetErrorMsg(sdeConnection.SeConnection, error);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                _errMsg = "SDE ERROR: " + ex.Message;
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        protected override SdeConnection OpenConnection(IDataset dataset)
        {
            _errMsg = "";

            SdeConnection connection = new SdeConnection(dataset);

            string server   = ConfigTextStream.ExtractValue(_connectionString, "server");
            string instance = ConfigTextStream.ExtractValue(_connectionString, "instance");
            string database = ConfigTextStream.ExtractValue(_connectionString, "database");
            string username = ConfigTextStream.ExtractValue(_connectionString, "usr");
            string password = ConfigTextStream.ExtractValue(_connectionString, "pwd");

            SE_ERROR error = new SE_ERROR();

            try
            {
                if (Wrapper10.SE_connection_create(
                        server,
                        instance,
                        database,
                        username,
                        password,
                        ref error,
                        ref connection.SeConnection) != 0)
                {
                    _errMsg = Wrapper10.GetErrorMsg(connection.SeConnection, error);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                _errMsg = "SDE ERROR: " + ex.Message;
                return(null);
            }
            return(connection);
        }