Пример #1
0
        public string QuoteIdentifier(string unquotedIdentifier, OleDbConnection connection)
        {
            ADP.CheckArgumentNull(unquotedIdentifier, "unquotedIdentifier");

            // if the user has specificed a prefix use the user specified  prefix and suffix
            // otherwise get them from the provider
            string quotePrefix = QuotePrefix;
            string quoteSuffix = QuoteSuffix;

            if (ADP.IsEmpty(quotePrefix) == true)
            {
                if (connection == null)
                {
                    // Use the adapter's connection if QuoteIdentifier was called from
                    // DbCommandBuilder instance (which does not have an overload that gets connection object)
                    connection = DataAdapter?.SelectCommand?.Connection;
                    if (connection == null)
                    {
                        throw ADP.QuotePrefixNotSet(ADP.QuoteIdentifier);
                    }
                }
                connection.GetLiteralQuotes(ADP.QuoteIdentifier, out quotePrefix, out quoteSuffix);
                // if the quote suffix is null assume that it is the same as the prefix (See OLEDB spec
                // IDBInfo::GetLiteralInfo DBLITERAL_QUOTE_SUFFIX.)
                if (quoteSuffix == null)
                {
                    quoteSuffix = quotePrefix;
                }
            }

            return(ADP.BuildQuotedString(quotePrefix, quoteSuffix, unquotedIdentifier));
        }
        public string QuoteIdentifier(string unquotedIdentifier, OdbcConnection connection)
        {
            ADP.CheckArgumentNull(unquotedIdentifier, "unquotedIdentifier");
            string quotePrefix = this.QuotePrefix;
            string quoteSuffix = this.QuoteSuffix;

            if (ADP.IsEmpty(quotePrefix))
            {
                if (connection == null)
                {
                    connection = base.GetConnection() as OdbcConnection;
                    if (connection == null)
                    {
                        throw ADP.QuotePrefixNotSet("QuoteIdentifier");
                    }
                }
                quotePrefix = connection.QuoteChar("QuoteIdentifier");
                quoteSuffix = quotePrefix;
            }
            if (!ADP.IsEmpty(quotePrefix) && (quotePrefix != " "))
            {
                return(ADP.BuildQuotedString(quotePrefix, quoteSuffix, unquotedIdentifier));
            }
            return(unquotedIdentifier);
        }
        public override string QuoteIdentifier(string unquotedIdentifier)
        {
            ADP.CheckArgumentNull(unquotedIdentifier, "unquotedIdentifier");
            string quoteSuffix = this.QuoteSuffix;
            string quotePrefix = this.QuotePrefix;

            this.ConsistentQuoteDelimiters(quotePrefix, quoteSuffix);
            return(ADP.BuildQuotedString(quotePrefix, quoteSuffix, unquotedIdentifier));
        }
Пример #4
0
        public override string QuoteIdentifier(string unquotedIdentifier)
        {
            ADP.CheckArgumentNull(unquotedIdentifier, nameof(unquotedIdentifier));
            string quoteSuffixLocal = QuoteSuffix;
            string quotePrefixLocal = QuotePrefix;

            ConsistentQuoteDelimiters(quotePrefixLocal, quoteSuffixLocal);
            return(ADP.BuildQuotedString(quotePrefixLocal, quoteSuffixLocal, unquotedIdentifier));
        }
Пример #5
0
        public string QuoteIdentifier(string unquotedIdentifier, OdbcConnection connection)
        {
            ADP.CheckArgumentNull(unquotedIdentifier, "unquotedIdentifier");

            // if the user has specificed a prefix use the user specified  prefix and suffix
            // otherwise get them from the provider
            string quotePrefix = QuotePrefix;
            string quoteSuffix = QuoteSuffix;

            if (ADP.IsEmpty(quotePrefix) == true)
            {
                if (connection == null)
                {
                    // VSTFDEVDIV 479567: use the adapter's connection if QuoteIdentifier was called from
                    // DbCommandBuilder instance (which does not have an overload that gets connection object)
                    connection = base.GetConnection() as OdbcConnection;
                    if (connection == null)
                    {
                        throw ADP.QuotePrefixNotSet(ADP.QuoteIdentifier);
                    }
                }
                quotePrefix = connection.QuoteChar(ADP.QuoteIdentifier);
                quoteSuffix = quotePrefix;
            }

            // by the ODBC spec "If the data source does not support quoted identifiers, a blank is returned."
            // So if a blank is returned the string is returned unchanged. Otherwise the returned string is used
            // to quote the string
            if ((ADP.IsEmpty(quotePrefix) == false) && (quotePrefix != " "))
            {
                return(ADP.BuildQuotedString(quotePrefix, quoteSuffix, unquotedIdentifier));
            }
            else
            {
                return(unquotedIdentifier);
            }
        }
Пример #6
0
        public string QuoteIdentifier(string unquotedIdentifier, OdbcConnection?connection)
        {
            ADP.CheckArgumentNull(unquotedIdentifier, nameof(unquotedIdentifier));

            // if the user has specificed a prefix use the user specified  prefix and suffix
            // otherwise get them from the provider
            string quotePrefix = QuotePrefix;
            string quoteSuffix = QuoteSuffix;

            if (string.IsNullOrEmpty(quotePrefix))
            {
                if (connection == null)
                {
                    // Use the adapter's connection if QuoteIdentifier was called from
                    // DbCommandBuilder instance (which does not have an overload that gets connection object)
                    connection = DataAdapter?.SelectCommand?.Connection;
                    if (connection == null)
                    {
                        throw ADP.QuotePrefixNotSet(ADP.QuoteIdentifier);
                    }
                }
                quotePrefix = connection.QuoteChar(ADP.QuoteIdentifier);
                quoteSuffix = quotePrefix;
            }

            // by the ODBC spec "If the data source does not support quoted identifiers, a blank is returned."
            // So if a blank is returned the string is returned unchanged. Otherwise the returned string is used
            // to quote the string
            if (!string.IsNullOrEmpty(quotePrefix) && quotePrefix != " ")
            {
                return(ADP.BuildQuotedString(quotePrefix, quoteSuffix, unquotedIdentifier));
            }
            else
            {
                return(unquotedIdentifier);
            }
        }
Пример #7
0
        public string QuoteIdentifier(string unquotedIdentifier, OleDbConnection connection)
        {
            ADP.CheckArgumentNull(unquotedIdentifier, "unquotedIdentifier");
            string quotePrefix = this.QuotePrefix;
            string quoteSuffix = this.QuoteSuffix;

            if (ADP.IsEmpty(quotePrefix))
            {
                if (connection == null)
                {
                    connection = base.GetConnection() as OleDbConnection;
                    if (connection == null)
                    {
                        throw ADP.QuotePrefixNotSet("QuoteIdentifier");
                    }
                }
                connection.GetLiteralQuotes("QuoteIdentifier", out quotePrefix, out quoteSuffix);
                if (quoteSuffix == null)
                {
                    quoteSuffix = quotePrefix;
                }
            }
            return(ADP.BuildQuotedString(quotePrefix, quoteSuffix, unquotedIdentifier));
        }