当前位置: 首页>>代码示例>>C#>>正文


C# OdbcConnection.QuoteChar方法代码示例

本文整理汇总了C#中System.Data.Odbc.OdbcConnection.QuoteChar方法的典型用法代码示例。如果您正苦于以下问题:C# OdbcConnection.QuoteChar方法的具体用法?C# OdbcConnection.QuoteChar怎么用?C# OdbcConnection.QuoteChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.Odbc.OdbcConnection的用法示例。


在下文中一共展示了OdbcConnection.QuoteChar方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UnquoteIdentifier

        public string UnquoteIdentifier(string quotedIdentifier, OdbcConnection connection){

            ADP.CheckArgumentNull(quotedIdentifier, "quotedIdentifier");


            // 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 UnquoteIdentifier 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.UnquoteIdentifier);
                    }
                }
                quotePrefix = connection.QuoteChar(ADP.UnquoteIdentifier);
                quoteSuffix = quotePrefix;
            }

            String unquotedIdentifier;
            // 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 unquote the string
            if ((ADP.IsEmpty(quotePrefix) == false) || (quotePrefix != " ")) {
                // ignoring the return value because it is acceptable for the quotedString to not be quoted in this
                // context.
                ADP.RemoveStringQuotes(quotePrefix, quoteSuffix, quotedIdentifier, out unquotedIdentifier);
            }
            else {
                unquotedIdentifier = quotedIdentifier;
            }
            return unquotedIdentifier;

        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:37,代码来源:OdbcCommandBuilder.cs

示例2: DeriveParametersFromStoredProcedure

        // DeriveParametersFromStoredProcedure (
        //  OdbcConnection connection,
        //  OdbcCommand command);
        //
        // Uses SQLProcedureColumns to create an array of OdbcParameters
        //

        static private OdbcParameter[] DeriveParametersFromStoredProcedure(OdbcConnection connection, OdbcCommand command) {
            List<OdbcParameter> rParams = new List<OdbcParameter>();

            // following call ensures that the command has a statement handle allocated
            CMDWrapper cmdWrapper = command.GetStatementHandle();
            OdbcStatementHandle hstmt = cmdWrapper.StatementHandle;
            int cColsAffected;

            // maps an enforced 4-part qualified string as follows
            // parts[0] = null  - ignored but removal would be a run-time breaking change from V1.0
            // parts[1] = CatalogName (optional, may be null)
            // parts[2] = SchemaName (optional, may be null)
            // parts[3] = ProcedureName
            //
            string quote = connection.QuoteChar(ADP.DeriveParameters);
            string[] parts = MultipartIdentifier.ParseMultipartIdentifier(command.CommandText, quote, quote, '.', 4, true, Res.ODBC_ODBCCommandText, false);          
            if (null == parts[3]) { // match everett behavior, if the commandtext is nothing but whitespace set the command text to the whitespace
                parts[3] = command.CommandText;
            }
            // note: native odbc appears to ignore all but the procedure name
            ODBC32.RetCode retcode = hstmt.ProcedureColumns(parts[1], parts[2], parts[3], null);

            // Note: the driver does not return an error if the given stored procedure does not exist
            // therefore we cannot handle that case and just return not parameters.

            if (ODBC32.RetCode.SUCCESS != retcode) {
                connection.HandleError(hstmt, retcode);
            }

            using (OdbcDataReader reader = new OdbcDataReader(command, cmdWrapper, CommandBehavior.Default)) {
                reader.FirstResult();
                cColsAffected = reader.FieldCount;

                // go through the returned rows and filter out relevant parameter data
                //
                while (reader.Read()) {
                    // devnote: column types are specified in the ODBC Programmer's Reference
                    // COLUMN_TYPE      Smallint    16bit
                    // COLUMN_SIZE      Integer     32bit
                    // DECIMAL_DIGITS   Smallint    16bit
                    // NUM_PREC_RADIX   Smallint    16bit

                    OdbcParameter parameter = new OdbcParameter();

                    parameter.ParameterName = reader.GetString(ODBC32.COLUMN_NAME-1);
                    switch ((ODBC32.SQL_PARAM)reader.GetInt16(ODBC32.COLUMN_TYPE-1)){
                        case ODBC32.SQL_PARAM.INPUT:
                            parameter.Direction = ParameterDirection.Input;
                            break;
                        case ODBC32.SQL_PARAM.OUTPUT:
                            parameter.Direction = ParameterDirection.Output;
                            break;

                        case ODBC32.SQL_PARAM.INPUT_OUTPUT:
                            parameter.Direction = ParameterDirection.InputOutput;
                            break;
                        case ODBC32.SQL_PARAM.RETURN_VALUE:
                            parameter.Direction = ParameterDirection.ReturnValue;
                            break;
                        default:
                            Debug.Assert(false, "Unexpected Parametertype while DeriveParamters");
                            break;
                    }
                    parameter.OdbcType = TypeMap.FromSqlType((ODBC32.SQL_TYPE)reader.GetInt16(ODBC32.DATA_TYPE-1))._odbcType;
                    parameter.Size = (int)reader.GetInt32(ODBC32.COLUMN_SIZE-1);
                    switch(parameter.OdbcType){
                        case OdbcType.Decimal:
                        case OdbcType.Numeric:
                            parameter.ScaleInternal = (Byte)reader.GetInt16(ODBC32.DECIMAL_DIGITS-1);
                            parameter.PrecisionInternal = (Byte)reader.GetInt16(ODBC32.NUM_PREC_RADIX-1);
                        break;
                    }
                    rParams.Add (parameter);
                }
            }
            retcode = hstmt.CloseCursor();
            return rParams.ToArray();;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:85,代码来源:OdbcCommandBuilder.cs

示例3: QuoteIdentifier

        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;
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:31,代码来源:OdbcCommandBuilder.cs

示例4: GetDataSourceInformationCollection


//.........这里部分代码省略.........
/* COLLATE is new in ODBC 3.0 and GroupByBehavior does not have a value for it.
                    case ODBC32.SQL_GROUP_BY.COLLATE:
                        groupByBehavior = Common.GroupByBehavior.Unknown;
                        break;
*/
                }
            }

            dataSourceInformation[DbMetaDataColumnNames.GroupByBehavior] = groupByBehavior;

            // determine the identifier case
            retcode = connection.GetInfoInt16Unhandled(ODBC32.SQL_INFO.IDENTIFIER_CASE, out int16Value);
            Common.IdentifierCase identifierCase = Common.IdentifierCase.Unknown;

            if ((retcode == ODBC32.RetCode.SUCCESS) || (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO)){

                switch (int16Value) {

                    case (Int16)ODBC32.SQL_IDENTIFIER_CASE.SENSITIVE:
                        identifierCase = Common.IdentifierCase.Sensitive;
                        break;

                    case (Int16)ODBC32.SQL_IDENTIFIER_CASE.UPPER:
                    case (Int16)ODBC32.SQL_IDENTIFIER_CASE.LOWER:
                    case (Int16)ODBC32.SQL_IDENTIFIER_CASE.MIXED:
                        identifierCase = Common.IdentifierCase.Insensitive;
                        break;

                }
            }
            dataSourceInformation[DbMetaDataColumnNames.IdentifierCase] = identifierCase;

            // OrderByColumnsInSelect
            stringValue = connection.GetInfoStringUnhandled(ODBC32.SQL_INFO.ORDER_BY_COLUMNS_IN_SELECT);
            if (stringValue != null) {
                if (stringValue == "Y"){
                    dataSourceInformation[DbMetaDataColumnNames.OrderByColumnsInSelect] = true;
                }
                else if (stringValue == "N") {
                    dataSourceInformation[DbMetaDataColumnNames.OrderByColumnsInSelect] = false;
                }
            }

            // build the QuotedIdentifierPattern using the quote prefix and suffix from the provider and
            // assuming that the quote suffix is escaped via repetion (i.e " becomes "")
            stringValue = connection.QuoteChar(ADP.GetSchema);

            if (stringValue != null){

                // by spec a blank identifier quote char indicates that the provider does not suppport
                // quoted identifiers
                if (stringValue != " ") {

                    // only know how to build the parttern if the quote characters is 1 character
                    // in all other cases just leave the field null
                    if (stringValue.Length == 1) {
                        StringBuilder scratchStringBuilder = new StringBuilder();
                        ADP.EscapeSpecialCharacters(stringValue,scratchStringBuilder );
                        string escapedQuoteSuffixString = scratchStringBuilder.ToString();
                        scratchStringBuilder.Length = 0;

                        ADP.EscapeSpecialCharacters(stringValue, scratchStringBuilder);
                        scratchStringBuilder.Append("(([^");
                        scratchStringBuilder.Append(escapedQuoteSuffixString);
                        scratchStringBuilder.Append("]|");
                        scratchStringBuilder.Append(escapedQuoteSuffixString);
                        scratchStringBuilder.Append(escapedQuoteSuffixString);
                        scratchStringBuilder.Append(")*)");
                        scratchStringBuilder.Append(escapedQuoteSuffixString);
                        dataSourceInformation[DbMetaDataColumnNames.QuotedIdentifierPattern] = scratchStringBuilder.ToString();
                    }
                }
            }

            // determine the quoted identifier case
            retcode = connection.GetInfoInt16Unhandled(ODBC32.SQL_INFO.QUOTED_IDENTIFIER_CASE, out int16Value);
            Common.IdentifierCase quotedIdentifierCase = Common.IdentifierCase.Unknown;

            if ((retcode == ODBC32.RetCode.SUCCESS) || (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO)){

                switch (int16Value) {

                    case (Int16)ODBC32.SQL_IDENTIFIER_CASE.SENSITIVE:
                        quotedIdentifierCase = Common.IdentifierCase.Sensitive;
                        break;

                    case (Int16)ODBC32.SQL_IDENTIFIER_CASE.UPPER:
                    case (Int16)ODBC32.SQL_IDENTIFIER_CASE.LOWER:
                    case (Int16)ODBC32.SQL_IDENTIFIER_CASE.MIXED:
                        quotedIdentifierCase = Common.IdentifierCase.Insensitive;
                        break;

                }
            }
            dataSourceInformation[DbMetaDataColumnNames.QuotedIdentifierCase] = quotedIdentifierCase;

            dataSourceInformationTable.AcceptChanges();

            return dataSourceInformationTable;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:101,代码来源:odbcmetadatafactory.cs

示例5: GetDataSourceInformationCollection


//.........这里部分代码省略.........
                if ((num & 4) != 0)
                {
                    none |= SupportedJoinOperators.FullOuter;
                }
                if ((num & 0x20) != 0)
                {
                    none |= SupportedJoinOperators.Inner;
                }
                row[DbMetaDataColumnNames.SupportedJoinOperators] = none;
            }
            code = connection.GetInfoInt16Unhandled(ODBC32.SQL_INFO.GROUP_BY, out num2);
            GroupByBehavior unknown = GroupByBehavior.Unknown;
            if ((code == ODBC32.RetCode.SUCCESS) || (code == ODBC32.RetCode.SUCCESS_WITH_INFO))
            {
                switch (num2)
                {
                    case 0:
                        unknown = GroupByBehavior.NotSupported;
                        break;

                    case 1:
                        unknown = GroupByBehavior.ExactMatch;
                        break;

                    case 2:
                        unknown = GroupByBehavior.MustContainAll;
                        break;

                    case 3:
                        unknown = GroupByBehavior.Unrelated;
                        break;
                }
            }
            row[DbMetaDataColumnNames.GroupByBehavior] = unknown;
            code = connection.GetInfoInt16Unhandled(ODBC32.SQL_INFO.IDENTIFIER_CASE, out num2);
            IdentifierCase insensitive = IdentifierCase.Unknown;
            if ((code == ODBC32.RetCode.SUCCESS) || (code == ODBC32.RetCode.SUCCESS_WITH_INFO))
            {
                switch (num2)
                {
                    case 1:
                    case 2:
                    case 4:
                        insensitive = IdentifierCase.Insensitive;
                        break;

                    case 3:
                        insensitive = IdentifierCase.Sensitive;
                        break;
                }
            }
            row[DbMetaDataColumnNames.IdentifierCase] = insensitive;
            switch (connection.GetInfoStringUnhandled(ODBC32.SQL_INFO.ORDER_BY_COLUMNS_IN_SELECT))
            {
                case "Y":
                    row[DbMetaDataColumnNames.OrderByColumnsInSelect] = true;
                    break;

                case "N":
                    row[DbMetaDataColumnNames.OrderByColumnsInSelect] = false;
                    break;
            }
            infoStringUnhandled = connection.QuoteChar("GetSchema");
            if (((infoStringUnhandled != null) && (infoStringUnhandled != " ")) && (infoStringUnhandled.Length == 1))
            {
                StringBuilder builder = new StringBuilder();
                ADP.EscapeSpecialCharacters(infoStringUnhandled, builder);
                string str2 = builder.ToString();
                builder.Length = 0;
                ADP.EscapeSpecialCharacters(infoStringUnhandled, builder);
                builder.Append("(([^");
                builder.Append(str2);
                builder.Append("]|");
                builder.Append(str2);
                builder.Append(str2);
                builder.Append(")*)");
                builder.Append(str2);
                row[DbMetaDataColumnNames.QuotedIdentifierPattern] = builder.ToString();
            }
            code = connection.GetInfoInt16Unhandled(ODBC32.SQL_INFO.QUOTED_IDENTIFIER_CASE, out num2);
            IdentifierCase sensitive = IdentifierCase.Unknown;
            if ((code == ODBC32.RetCode.SUCCESS) || (code == ODBC32.RetCode.SUCCESS_WITH_INFO))
            {
                switch (num2)
                {
                    case 1:
                    case 2:
                    case 4:
                        sensitive = IdentifierCase.Insensitive;
                        break;

                    case 3:
                        sensitive = IdentifierCase.Sensitive;
                        break;
                }
            }
            row[DbMetaDataColumnNames.QuotedIdentifierCase] = sensitive;
            table.AcceptChanges();
            return table;
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:OdbcMetaDataFactory.cs

示例6: DeriveParametersFromStoredProcedure

        private static OdbcParameter[] DeriveParametersFromStoredProcedure(OdbcConnection connection, OdbcCommand command)
        {
            List<OdbcParameter> list = new List<OdbcParameter>();
            CMDWrapper statementHandle = command.GetStatementHandle();
            OdbcStatementHandle hrHandle = statementHandle.StatementHandle;
            string leftQuote = connection.QuoteChar("DeriveParameters");
            string[] strArray = MultipartIdentifier.ParseMultipartIdentifier(command.CommandText, leftQuote, leftQuote, '.', 4, true, "ODBC_ODBCCommandText", false);
            if (strArray[3] == null)
            {
                strArray[3] = command.CommandText;
            }
            ODBC32.RetCode retcode = hrHandle.ProcedureColumns(strArray[1], strArray[2], strArray[3], null);
            if (retcode != ODBC32.RetCode.SUCCESS)
            {
                connection.HandleError(hrHandle, retcode);
            }
            using (OdbcDataReader reader = new OdbcDataReader(command, statementHandle, CommandBehavior.Default))
            {
                reader.FirstResult();
                int fieldCount = reader.FieldCount;
                while (reader.Read())
                {
                    OdbcParameter item = new OdbcParameter {
                        ParameterName = reader.GetString(3)
                    };
                    switch (reader.GetInt16(4))
                    {
                        case 1:
                            item.Direction = ParameterDirection.Input;
                            break;

                        case 2:
                            item.Direction = ParameterDirection.InputOutput;
                            break;

                        case 4:
                            item.Direction = ParameterDirection.Output;
                            break;

                        case 5:
                            item.Direction = ParameterDirection.ReturnValue;
                            break;
                    }
                    item.OdbcType = TypeMap.FromSqlType((ODBC32.SQL_TYPE) reader.GetInt16(5))._odbcType;
                    item.Size = reader.GetInt32(7);
                    switch (item.OdbcType)
                    {
                        case OdbcType.Decimal:
                        case OdbcType.Numeric:
                            item.ScaleInternal = (byte) reader.GetInt16(9);
                            item.PrecisionInternal = (byte) reader.GetInt16(10);
                            break;
                    }
                    list.Add(item);
                }
            }
            retcode = hrHandle.CloseCursor();
            return list.ToArray();
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:59,代码来源:OdbcCommandBuilder.cs

示例7: UnquoteIdentifier

 public string UnquoteIdentifier(string quotedIdentifier, OdbcConnection connection)
 {
     ADP.CheckArgumentNull(quotedIdentifier, "quotedIdentifier");
     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("UnquoteIdentifier");
             }
         }
         quotePrefix = connection.QuoteChar("UnquoteIdentifier");
         quoteSuffix = quotePrefix;
     }
     if (!ADP.IsEmpty(quotePrefix) || (quotePrefix != " "))
     {
         string str2;
         ADP.RemoveStringQuotes(quotePrefix, quoteSuffix, quotedIdentifier, out str2);
         return str2;
     }
     return quotedIdentifier;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:OdbcCommandBuilder.cs

示例8: QuoteIdentifier

 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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:OdbcCommandBuilder.cs


注:本文中的System.Data.Odbc.OdbcConnection.QuoteChar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。