コード例 #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 error = new SE_ERROR();

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

            return(true);
        }
コード例 #2
0
ファイル: SdeConnection.cs プロジェクト: jugstalt/gViewGisOS
        protected override SdeConnection OpenConnection(IDataset dataset)
        {
            _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 error = new SE_ERROR();

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