예제 #1
0
        private bool OpenConnection(SdeConnection SdeConnection)
        {
            if (SdeConnection.SeConnection.handle != 0)
            {
                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");

            SE_ERROR_64 error = new SE_ERROR_64();

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

            return(true);
        }
예제 #2
0
        protected override SdeConnection OpenConnection()
        {
            _errMsg = "";

            SdeConnection connection = new 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");

            SE_ERROR_64 error = new SE_ERROR_64();

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