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 UnquoteIdentifier(string quotedIdentifier, OleDbConnection connection) { string str3; ADP.CheckArgumentNull(quotedIdentifier, "quotedIdentifier"); 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("UnquoteIdentifier"); } } connection.GetLiteralQuotes("UnquoteIdentifier", out quotePrefix, out quoteSuffix); if (quoteSuffix == null) { quoteSuffix = quotePrefix; } } ADP.RemoveStringQuotes(quotePrefix, quoteSuffix, quotedIdentifier, out str3); return(str3); }
public string UnquoteIdentifier(string quotedIdentifier, OleDbConnection 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 OleDbConnection; if (connection == null) { throw ADP.QuotePrefixNotSet(ADP.UnquoteIdentifier); } } connection.GetLiteralQuotes(ADP.UnquoteIdentifier, 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; } } String unquotedIdentifier; // 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); return(unquotedIdentifier); }
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)); }
// known difference: when getting the parameters for a sproc, the // return value gets marked as a return value but for a sql stmt // the return value gets marked as an output parameter. private static OleDbParameter[] DeriveParametersFromStoredProcedure(OleDbConnection connection, OleDbCommand command) { OleDbParameter[] plist = Array.Empty <OleDbParameter>(); if (connection.SupportSchemaRowset(OleDbSchemaGuid.Procedure_Parameters)) { string quotePrefix, quoteSuffix; connection.GetLiteralQuotes(ADP.DeriveParameters, out quotePrefix, out quoteSuffix); object?[] parsed = MultipartIdentifier.ParseMultipartIdentifier(command.CommandText, quotePrefix, quoteSuffix, '.', 4, true, SR.OLEDB_OLEDBCommandText, false); if (null == parsed[3]) { throw ADP.NoStoredProcedureExists(command.CommandText); } object?[] restrictions = new object[4]; object value; // Parse returns an enforced 4 part array // 0) Server - ignored but removal would be a run-time breaking change from V1.0 // 1) Catalog // 2) Schema // 3) ProcedureName // Restrictions array which is passed to OleDb API expects: // 0) Catalog // 1) Schema // 2) ProcedureName // 3) ParameterName (leave null) // Copy from Parse format to OleDb API format Array.Copy(parsed, 1, restrictions, 0, 3); //if (cmdConnection.IsServer_msdaora) { // restrictions[1] = Convert.ToString(cmdConnection.UserId).ToUpper(); //} DataTable?table = connection.GetSchemaRowset(OleDbSchemaGuid.Procedure_Parameters, restrictions); if (null != table) { DataColumnCollection columns = table.Columns; DataColumn?parameterName = null; DataColumn?parameterDirection = null; DataColumn?dataType = null; DataColumn?maxLen = null; DataColumn?numericPrecision = null; DataColumn?numericScale = null; DataColumn?backendtype = null; int index = columns.IndexOf(ODB.PARAMETER_NAME); if (-1 != index) { parameterName = columns[index]; } index = columns.IndexOf(ODB.PARAMETER_TYPE); if (-1 != index) { parameterDirection = columns[index]; } index = columns.IndexOf(ODB.DATA_TYPE); if (-1 != index) { dataType = columns[index]; } index = columns.IndexOf(ODB.CHARACTER_MAXIMUM_LENGTH); if (-1 != index) { maxLen = columns[index]; } index = columns.IndexOf(ODB.NUMERIC_PRECISION); if (-1 != index) { numericPrecision = columns[index]; } index = columns.IndexOf(ODB.NUMERIC_SCALE); if (-1 != index) { numericScale = columns[index]; } index = columns.IndexOf(ODB.TYPE_NAME); if (-1 != index) { backendtype = columns[index]; } DataRow[] dataRows = table.Select(null, ODB.ORDINAL_POSITION_ASC, DataViewRowState.CurrentRows); plist = new OleDbParameter[dataRows.Length]; for (index = 0; index < dataRows.Length; ++index) { DataRow dataRow = dataRows[index]; OleDbParameter parameter = new OleDbParameter(); if ((null != parameterName) && !dataRow.IsNull(parameterName, DataRowVersion.Default)) { // $CONSIDER - not trimming the @ from the beginning but to left the designer do that parameter.ParameterName = Convert.ToString(dataRow[parameterName, DataRowVersion.Default], CultureInfo.InvariantCulture) !.TrimStart(new char[] { '@', ' ', ':' }); } if ((null != parameterDirection) && !dataRow.IsNull(parameterDirection, DataRowVersion.Default)) { short direction = Convert.ToInt16(dataRow[parameterDirection, DataRowVersion.Default], CultureInfo.InvariantCulture); parameter.Direction = ConvertToParameterDirection(direction); } if ((null != dataType) && !dataRow.IsNull(dataType, DataRowVersion.Default)) { // need to ping FromDBType, otherwise WChar->WChar when the user really wants VarWChar short wType = Convert.ToInt16(dataRow[dataType, DataRowVersion.Default], CultureInfo.InvariantCulture); parameter.OleDbType = NativeDBType.FromDBType(wType, false, false).enumOleDbType; } if ((null != maxLen) && !dataRow.IsNull(maxLen, DataRowVersion.Default)) { parameter.Size = Convert.ToInt32(dataRow[maxLen, DataRowVersion.Default], CultureInfo.InvariantCulture); } switch (parameter.OleDbType) { case OleDbType.Decimal: case OleDbType.Numeric: case OleDbType.VarNumeric: if ((null != numericPrecision) && !dataRow.IsNull(numericPrecision, DataRowVersion.Default)) { // @devnote: unguarded cast from Int16 to Byte parameter.PrecisionInternal = (byte)Convert.ToInt16(dataRow[numericPrecision], CultureInfo.InvariantCulture); } if ((null != numericScale) && !dataRow.IsNull(numericScale, DataRowVersion.Default)) { // @devnote: unguarded cast from Int16 to Byte parameter.ScaleInternal = (byte)Convert.ToInt16(dataRow[numericScale], CultureInfo.InvariantCulture); } break; case OleDbType.VarBinary: case OleDbType.VarChar: case OleDbType.VarWChar: value = dataRow[backendtype !, DataRowVersion.Default];
// known difference: when getting the parameters for a sproc, the // return value gets marked as a return value but for a sql stmt // the return value gets marked as an output parameter. static private OleDbParameter[] DeriveParametersFromStoredProcedure(OleDbConnection connection, OleDbCommand command) { OleDbParameter[] plist = new OleDbParameter[0]; if (connection.SupportSchemaRowset(OleDbSchemaGuid.Procedure_Parameters)) { string quotePrefix, quoteSuffix; connection.GetLiteralQuotes(ADP.DeriveParameters, out quotePrefix, out quoteSuffix); Object[] parsed = MultipartIdentifier.ParseMultipartIdentifier(command.CommandText, quotePrefix, quoteSuffix, '.', 4, true, SR.OLEDB_OLEDBCommandText, false); if (null == parsed[3]) { throw ADP.NoStoredProcedureExists(command.CommandText); } Object[] restrictions = new object[4]; object value; // Parse returns an enforced 4 part array // 0) Server - ignored but removal would be a run-time breaking change from V1.0 // 1) Catalog // 2) Schema // 3) ProcedureName // Restrictions array which is passed to OleDb API expects: // 0) Catalog // 1) Schema // 2) ProcedureName // 3) ParameterName (leave null) // Copy from Parse format to OleDb API format Array.Copy(parsed, 1, restrictions, 0, 3); //if (cmdConnection.IsServer_msdaora) { // restrictions[1] = Convert.ToString(cmdConnection.UserId).ToUpper(); //} DataTable table = connection.GetSchemaRowset(OleDbSchemaGuid.Procedure_Parameters, restrictions); if (null != table) { DataColumnCollection columns = table.Columns; DataColumn parameterName = null; DataColumn parameterDirection = null; DataColumn dataType = null; DataColumn maxLen = null; DataColumn numericPrecision = null; DataColumn numericScale = null; DataColumn backendtype = null; int index = columns.IndexOf(ODB.PARAMETER_NAME); if (-1 != index) { parameterName = columns[index]; } index = columns.IndexOf(ODB.PARAMETER_TYPE); if (-1 != index) { parameterDirection = columns[index]; } index = columns.IndexOf(ODB.DATA_TYPE); if (-1 != index) { dataType = columns[index]; } index = columns.IndexOf(ODB.CHARACTER_MAXIMUM_LENGTH); if (-1 != index) { maxLen = columns[index]; } index = columns.IndexOf(ODB.NUMERIC_PRECISION); if (-1 != index) { numericPrecision = columns[index]; } index = columns.IndexOf(ODB.NUMERIC_SCALE); if (-1 != index) { numericScale = columns[index]; } index = columns.IndexOf(ODB.TYPE_NAME); if (-1 != index) { backendtype = columns[index]; } DataRow[] dataRows = table.Select(null, ODB.ORDINAL_POSITION_ASC, DataViewRowState.CurrentRows); plist = new OleDbParameter[dataRows.Length]; for (index = 0; index < dataRows.Length; ++index) { DataRow dataRow = dataRows[index]; OleDbParameter parameter = new OleDbParameter(); if ((null != parameterName) && !dataRow.IsNull(parameterName, DataRowVersion.Default)) { // $CONSIDER - not trimming the @ from the beginning but to left the designer do that parameter.ParameterName = Convert.ToString(dataRow[parameterName, DataRowVersion.Default], CultureInfo.InvariantCulture).TrimStart(new char[] { '@', ' ', ':' }); } if ((null != parameterDirection) && !dataRow.IsNull(parameterDirection, DataRowVersion.Default)) { short direction = Convert.ToInt16(dataRow[parameterDirection, DataRowVersion.Default], CultureInfo.InvariantCulture); parameter.Direction = ConvertToParameterDirection(direction); } if ((null != dataType) && !dataRow.IsNull(dataType, DataRowVersion.Default)) { // need to ping FromDBType, otherwise WChar->WChar when the user really wants VarWChar short wType = Convert.ToInt16(dataRow[dataType, DataRowVersion.Default], CultureInfo.InvariantCulture); parameter.OleDbType = NativeDBType.FromDBType(wType, false, false).enumOleDbType; } if ((null != maxLen) && !dataRow.IsNull(maxLen, DataRowVersion.Default)) { parameter.Size = Convert.ToInt32(dataRow[maxLen, DataRowVersion.Default], CultureInfo.InvariantCulture); } switch (parameter.OleDbType) { case OleDbType.Decimal: case OleDbType.Numeric: case OleDbType.VarNumeric: if ((null != numericPrecision) && !dataRow.IsNull(numericPrecision, DataRowVersion.Default)) { // @devnote: unguarded cast from Int16 to Byte parameter.PrecisionInternal = (Byte)Convert.ToInt16(dataRow[numericPrecision], CultureInfo.InvariantCulture); } if ((null != numericScale) && !dataRow.IsNull(numericScale, DataRowVersion.Default)) { // @devnote: unguarded cast from Int16 to Byte parameter.ScaleInternal = (Byte)Convert.ToInt16(dataRow[numericScale], CultureInfo.InvariantCulture); } break; case OleDbType.VarBinary: case OleDbType.VarChar: case OleDbType.VarWChar: value = dataRow[backendtype, DataRowVersion.Default]; if (value is string) { string backendtypename = ((string)value).ToLower(CultureInfo.InvariantCulture); switch (backendtypename) { case "binary": parameter.OleDbType = OleDbType.Binary; break; //case "varbinary": // parameter.OleDbType = OleDbType.VarBinary; // break; case "image": parameter.OleDbType = OleDbType.LongVarBinary; break; case "char": parameter.OleDbType = OleDbType.Char; break; //case "varchar": //case "varchar2": // parameter.OleDbType = OleDbType.VarChar; // break; case "text": parameter.OleDbType = OleDbType.LongVarChar; break; case "nchar": parameter.OleDbType = OleDbType.WChar; break; //case "nvarchar": // parameter.OleDbType = OleDbType.VarWChar; case "ntext": parameter.OleDbType = OleDbType.LongVarWChar; break; } } break; } //if (AdapterSwitches.OleDbSql.TraceVerbose) { // ADP.Trace_Parameter("StoredProcedure", parameter); //} plist[index] = parameter; } } if ((0 == plist.Length) && connection.SupportSchemaRowset(OleDbSchemaGuid.Procedures)) { restrictions = new Object[4] { null, null, command.CommandText, null }; table = connection.GetSchemaRowset(OleDbSchemaGuid.Procedures, restrictions); if (0 == table.Rows.Count) { throw ADP.NoStoredProcedureExists(command.CommandText); } } } else if (connection.SupportSchemaRowset(OleDbSchemaGuid.Procedures)) { Object[] restrictions = new Object[4] { null, null, command.CommandText, null }; DataTable table = connection.GetSchemaRowset(OleDbSchemaGuid.Procedures, restrictions); if (0 == table.Rows.Count) { throw ADP.NoStoredProcedureExists(command.CommandText); } // we don't ever expect a procedure with 0 parameters, they should have at least a return value throw ODB.NoProviderSupportForSProcResetParameters(connection.Provider); } else { throw ODB.NoProviderSupportForSProcResetParameters(connection.Provider); } return(plist); }
private DataTable GetDataSourceInformationTable(OleDbConnection connection, OleDbConnectionInternal internalConnection) { // verify that the data source information table is in the data set DataTable dataSourceInformationTable = CollectionDataSet.Tables[DbMetaDataCollectionNames.DataSourceInformation]; if (dataSourceInformationTable == null) { throw ADP.UnableToBuildCollection(DbMetaDataCollectionNames.DataSourceInformation); } // copy the table filtering out any rows that don't apply to tho current version of the prrovider dataSourceInformationTable = CloneAndFilterCollection(DbMetaDataCollectionNames.DataSourceInformation, null); // after filtering there better be just one row if (dataSourceInformationTable.Rows.Count != 1) { throw ADP.IncorrectNumberOfDataSourceInformationRows(); } DataRow dataSourceInformation = dataSourceInformationTable.Rows[0]; // update the identifier separator string catalogSeparatorPattern = internalConnection.GetLiteralInfo(ODB.DBLITERAL_CATALOG_SEPARATOR); string schemaSeparatorPattern = internalConnection.GetLiteralInfo(ODB.DBLITERAL_SCHEMA_SEPARATOR); if (catalogSeparatorPattern != null) { StringBuilder compositeSeparatorPattern = new StringBuilder(); StringBuilder patternEscaped = new StringBuilder(); ADP.EscapeSpecialCharacters(catalogSeparatorPattern, patternEscaped); compositeSeparatorPattern.Append(patternEscaped.ToString()); if ((schemaSeparatorPattern != null) && (schemaSeparatorPattern != catalogSeparatorPattern)) { compositeSeparatorPattern.Append("|"); patternEscaped.Length = 0; ADP.EscapeSpecialCharacters(schemaSeparatorPattern, patternEscaped); compositeSeparatorPattern.Append(patternEscaped.ToString()); } dataSourceInformation[DbMetaDataColumnNames.CompositeIdentifierSeparatorPattern] = compositeSeparatorPattern.ToString(); } else if (schemaSeparatorPattern != null) { StringBuilder patternEscaped = new StringBuilder(); ADP.EscapeSpecialCharacters(schemaSeparatorPattern, patternEscaped); dataSourceInformation[DbMetaDataColumnNames.CompositeIdentifierSeparatorPattern] = patternEscaped.ToString(); ; } // update the DataSourceProductName object property; property = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo, ODB.DBPROP_DBMSNAME); if (property != null) { dataSourceInformation[DbMetaDataColumnNames.DataSourceProductName] = (string)property; } // update the server version strings dataSourceInformation[DbMetaDataColumnNames.DataSourceProductVersion] = ServerVersion; dataSourceInformation[DbMetaDataColumnNames.DataSourceProductVersionNormalized] = ServerVersionNormalized; // values that are the same for all OLE DB Providers. dataSourceInformation[DbMetaDataColumnNames.ParameterMarkerFormat] = "?"; dataSourceInformation[DbMetaDataColumnNames.ParameterMarkerPattern] = "\\?"; dataSourceInformation[DbMetaDataColumnNames.ParameterNameMaxLength] = 0; property = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo, ODB.DBPROP_GROUPBY); GroupByBehavior groupByBehavior = GroupByBehavior.Unknown; if (property != null) { switch ((int)property) { case ODB.DBPROPVAL_GB_CONTAINS_SELECT: groupByBehavior = GroupByBehavior.MustContainAll; break; case ODB.DBPROPVAL_GB_EQUALS_SELECT: groupByBehavior = GroupByBehavior.ExactMatch; break; case ODB.DBPROPVAL_GB_NO_RELATION: groupByBehavior = GroupByBehavior.Unrelated; break; case ODB.DBPROPVAL_GB_NOT_SUPPORTED: groupByBehavior = GroupByBehavior.NotSupported; break; } } dataSourceInformation[DbMetaDataColumnNames.GroupByBehavior] = groupByBehavior; SetIdentifierCase(DbMetaDataColumnNames.IdentifierCase, ODB.DBPROP_IDENTIFIERCASE, dataSourceInformation, connection); SetIdentifierCase(DbMetaDataColumnNames.QuotedIdentifierCase, ODB.DBPROP_QUOTEDIDENTIFIERCASE, dataSourceInformation, connection); property = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo, ODB.DBPROP_ORDERBYCOLUNSINSELECT); if (property != null) { dataSourceInformation[DbMetaDataColumnNames.OrderByColumnsInSelect] = (bool)property; } DataTable infoLiterals = internalConnection.BuildInfoLiterals(); if (infoLiterals != null) { DataRow[] tableNameRow = infoLiterals.Select("Literal = " + ODB.DBLITERAL_TABLE_NAME.ToString(CultureInfo.InvariantCulture)); if (tableNameRow != null) { object invalidCharsObject = tableNameRow[0]["InvalidChars"]; if (invalidCharsObject.GetType() == typeof(string)) { string invalidChars = (string)invalidCharsObject; object invalidStartingCharsObject = tableNameRow[0]["InvalidStartingChars"]; string invalidStartingChars; if (invalidStartingCharsObject.GetType() == typeof(string)) { invalidStartingChars = (string)invalidStartingCharsObject; } else { invalidStartingChars = invalidChars; } dataSourceInformation[DbMetaDataColumnNames.IdentifierPattern] = BuildRegularExpression(invalidChars, invalidStartingChars); } } } // 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 "") string quotePrefix; string quoteSuffix; connection.GetLiteralQuotes(ADP.GetSchema, out quotePrefix, out quoteSuffix); if (quotePrefix != null) { // 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; } // only know how to build the parttern if the suffix is 1 character // in all other cases just leave the field null if (quoteSuffix.Length == 1) { StringBuilder scratchStringBuilder = new StringBuilder(); ADP.EscapeSpecialCharacters(quoteSuffix, scratchStringBuilder); string escapedQuoteSuffixString = scratchStringBuilder.ToString(); scratchStringBuilder.Length = 0; ADP.EscapeSpecialCharacters(quotePrefix, scratchStringBuilder); scratchStringBuilder.Append("(([^"); scratchStringBuilder.Append(escapedQuoteSuffixString); scratchStringBuilder.Append("]|"); scratchStringBuilder.Append(escapedQuoteSuffixString); scratchStringBuilder.Append(escapedQuoteSuffixString); scratchStringBuilder.Append(")*)"); scratchStringBuilder.Append(escapedQuoteSuffixString); dataSourceInformation[DbMetaDataColumnNames.QuotedIdentifierPattern] = scratchStringBuilder.ToString(); } } dataSourceInformationTable.AcceptChanges(); return(dataSourceInformationTable); }
private DataTable GetDataSourceInformationTable(OleDbConnection connection, OleDbConnectionInternal internalConnection) { string str3; string str4; if (base.CollectionDataSet.Tables[DbMetaDataCollectionNames.DataSourceInformation] == null) { throw ADP.UnableToBuildCollection(DbMetaDataCollectionNames.DataSourceInformation); } DataTable table = base.CloneAndFilterCollection(DbMetaDataCollectionNames.DataSourceInformation, null); if (table.Rows.Count != 1) { throw ADP.IncorrectNumberOfDataSourceInformationRows(); } DataRow row = table.Rows[0]; string literalInfo = internalConnection.GetLiteralInfo(3); string unescapedString = internalConnection.GetLiteralInfo(0x1b); if (literalInfo != null) { StringBuilder builder3 = new StringBuilder(); StringBuilder escapedString = new StringBuilder(); ADP.EscapeSpecialCharacters(literalInfo, escapedString); builder3.Append(escapedString.ToString()); if ((unescapedString != null) && (unescapedString != literalInfo)) { builder3.Append("|"); escapedString.Length = 0; ADP.EscapeSpecialCharacters(unescapedString, escapedString); builder3.Append(escapedString.ToString()); } row[DbMetaDataColumnNames.CompositeIdentifierSeparatorPattern] = builder3.ToString(); } else if (unescapedString != null) { StringBuilder builder4 = new StringBuilder(); ADP.EscapeSpecialCharacters(unescapedString, builder4); row[DbMetaDataColumnNames.CompositeIdentifierSeparatorPattern] = builder4.ToString(); } object dataSourcePropertyValue = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo, 40); if (dataSourcePropertyValue != null) { row[DbMetaDataColumnNames.DataSourceProductName] = (string) dataSourcePropertyValue; } row[DbMetaDataColumnNames.DataSourceProductVersion] = base.ServerVersion; row[DbMetaDataColumnNames.DataSourceProductVersionNormalized] = base.ServerVersionNormalized; row[DbMetaDataColumnNames.ParameterMarkerFormat] = "?"; row[DbMetaDataColumnNames.ParameterMarkerPattern] = @"\?"; row[DbMetaDataColumnNames.ParameterNameMaxLength] = 0; dataSourcePropertyValue = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo, 0x2c); GroupByBehavior unknown = GroupByBehavior.Unknown; if (dataSourcePropertyValue != null) { switch (((int) dataSourcePropertyValue)) { case 1: unknown = GroupByBehavior.NotSupported; break; case 2: unknown = GroupByBehavior.ExactMatch; break; case 4: unknown = GroupByBehavior.MustContainAll; break; case 8: unknown = GroupByBehavior.Unrelated; break; } } row[DbMetaDataColumnNames.GroupByBehavior] = unknown; this.SetIdentifierCase(DbMetaDataColumnNames.IdentifierCase, 0x2e, row, connection); this.SetIdentifierCase(DbMetaDataColumnNames.QuotedIdentifierCase, 100, row, connection); dataSourcePropertyValue = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo, 0x55); if (dataSourcePropertyValue != null) { row[DbMetaDataColumnNames.OrderByColumnsInSelect] = (bool) dataSourcePropertyValue; } DataTable table2 = internalConnection.BuildInfoLiterals(); if (table2 != null) { DataRow[] rowArray = table2.Select("Literal = " + 0x11.ToString(CultureInfo.InvariantCulture)); if (rowArray != null) { object obj4 = rowArray[0]["InvalidChars"]; if (obj4.GetType() == typeof(string)) { string str6; string invalidChars = (string) obj4; object obj3 = rowArray[0]["InvalidStartingChars"]; if (obj3.GetType() == typeof(string)) { str6 = (string) obj3; } else { str6 = invalidChars; } row[DbMetaDataColumnNames.IdentifierPattern] = this.BuildRegularExpression(invalidChars, str6); } } } connection.GetLiteralQuotes("GetSchema", out str4, out str3); if (str4 != null) { if (str3 == null) { str3 = str4; } if (str3.Length == 1) { StringBuilder builder = new StringBuilder(); ADP.EscapeSpecialCharacters(str3, builder); string str2 = builder.ToString(); builder.Length = 0; ADP.EscapeSpecialCharacters(str4, builder); builder.Append("(([^"); builder.Append(str2); builder.Append("]|"); builder.Append(str2); builder.Append(str2); builder.Append(")*)"); builder.Append(str2); row[DbMetaDataColumnNames.QuotedIdentifierPattern] = builder.ToString(); } } table.AcceptChanges(); return table; }
private static OleDbParameter[] DeriveParametersFromStoredProcedure(OleDbConnection connection, OleDbCommand command) { OleDbParameter[] parameterArray = new OleDbParameter[0]; if (connection.SupportSchemaRowset(OleDbSchemaGuid.Procedure_Parameters)) { string str3; string str4; connection.GetLiteralQuotes("DeriveParameters", out str4, out str3); object[] sourceArray = MultipartIdentifier.ParseMultipartIdentifier(command.CommandText, str4, str3, '.', 4, true, "OLEDB_OLEDBCommandText", false); if (sourceArray[3] == null) { throw ADP.NoStoredProcedureExists(command.CommandText); } object[] destinationArray = new object[4]; Array.Copy(sourceArray, 1, destinationArray, 0, 3); DataTable schemaRowset = connection.GetSchemaRowset(OleDbSchemaGuid.Procedure_Parameters, destinationArray); if (schemaRowset != null) { DataColumnCollection columns = schemaRowset.Columns; DataColumn column6 = null; DataColumn column5 = null; DataColumn column4 = null; DataColumn column3 = null; DataColumn column2 = null; DataColumn column = null; DataColumn column7 = null; int index = columns.IndexOf("PARAMETER_NAME"); if (-1 != index) { column6 = columns[index]; } index = columns.IndexOf("PARAMETER_TYPE"); if (-1 != index) { column5 = columns[index]; } index = columns.IndexOf("DATA_TYPE"); if (-1 != index) { column4 = columns[index]; } index = columns.IndexOf("CHARACTER_MAXIMUM_LENGTH"); if (-1 != index) { column3 = columns[index]; } index = columns.IndexOf("NUMERIC_PRECISION"); if (-1 != index) { column2 = columns[index]; } index = columns.IndexOf("NUMERIC_SCALE"); if (-1 != index) { column = columns[index]; } index = columns.IndexOf("TYPE_NAME"); if (-1 != index) { column7 = columns[index]; } DataRow[] rowArray = schemaRowset.Select(null, "ORDINAL_POSITION ASC", DataViewRowState.CurrentRows); parameterArray = new OleDbParameter[rowArray.Length]; for (index = 0; index < rowArray.Length; index++) { DataRow row = rowArray[index]; OleDbParameter parameter = new OleDbParameter(); if ((column6 != null) && !row.IsNull(column6, DataRowVersion.Default)) { parameter.ParameterName = Convert.ToString(row[column6, DataRowVersion.Default], CultureInfo.InvariantCulture).TrimStart(new char[] { '@', ' ', ':' }); } if ((column5 != null) && !row.IsNull(column5, DataRowVersion.Default)) { short num3 = Convert.ToInt16(row[column5, DataRowVersion.Default], CultureInfo.InvariantCulture); parameter.Direction = ConvertToParameterDirection(num3); } if ((column4 != null) && !row.IsNull(column4, DataRowVersion.Default)) { short dbType = Convert.ToInt16(row[column4, DataRowVersion.Default], CultureInfo.InvariantCulture); parameter.OleDbType = NativeDBType.FromDBType(dbType, false, false).enumOleDbType; } if ((column3 != null) && !row.IsNull(column3, DataRowVersion.Default)) { parameter.Size = Convert.ToInt32(row[column3, DataRowVersion.Default], CultureInfo.InvariantCulture); } switch (parameter.OleDbType) { case OleDbType.VarChar: case OleDbType.VarWChar: case OleDbType.VarBinary: { string str; object obj2 = row[column7, DataRowVersion.Default]; if ((obj2 is string) && ((str = ((string)obj2).ToLower(CultureInfo.InvariantCulture)) != null)) { if (str == "binary") { break; } if (str == "image") { goto Label_03B9; } if (str == "char") { goto Label_03C6; } if (str == "text") { goto Label_03D3; } if (str == "nchar") { goto Label_03E0; } if (str == "ntext") { goto Label_03ED; } } goto Label_03F8; } case OleDbType.VarNumeric: case OleDbType.Decimal: case OleDbType.Numeric: if ((column2 != null) && !row.IsNull(column2, DataRowVersion.Default)) { parameter.PrecisionInternal = (byte)Convert.ToInt16(row[column2], CultureInfo.InvariantCulture); } if ((column != null) && !row.IsNull(column, DataRowVersion.Default)) { parameter.ScaleInternal = (byte)Convert.ToInt16(row[column], CultureInfo.InvariantCulture); } goto Label_03F8; default: goto Label_03F8; } parameter.OleDbType = OleDbType.Binary; goto Label_03F8; Label_03B9: parameter.OleDbType = OleDbType.LongVarBinary; goto Label_03F8; Label_03C6: parameter.OleDbType = OleDbType.Char; goto Label_03F8; Label_03D3: parameter.OleDbType = OleDbType.LongVarChar; goto Label_03F8; Label_03E0: parameter.OleDbType = OleDbType.WChar; goto Label_03F8; Label_03ED: parameter.OleDbType = OleDbType.LongVarWChar; Label_03F8: parameterArray[index] = parameter; } } if ((parameterArray.Length == 0) && connection.SupportSchemaRowset(OleDbSchemaGuid.Procedures)) { object[] objArray3 = new object[4]; objArray3[2] = command.CommandText; destinationArray = objArray3; if (connection.GetSchemaRowset(OleDbSchemaGuid.Procedures, destinationArray).Rows.Count == 0) { throw ADP.NoStoredProcedureExists(command.CommandText); } } return(parameterArray); } if (!connection.SupportSchemaRowset(OleDbSchemaGuid.Procedures)) { throw ODB.NoProviderSupportForSProcResetParameters(connection.Provider); } object[] objArray2 = new object[4]; objArray2[2] = command.CommandText; object[] restrictions = objArray2; if (connection.GetSchemaRowset(OleDbSchemaGuid.Procedures, restrictions).Rows.Count == 0) { throw ADP.NoStoredProcedureExists(command.CommandText); } throw ODB.NoProviderSupportForSProcResetParameters(connection.Provider); }
private DataTable GetDataSourceInformationTable(OleDbConnection connection, OleDbConnectionInternal internalConnection) { string str3; string str4; if (base.CollectionDataSet.Tables[DbMetaDataCollectionNames.DataSourceInformation] == null) { throw ADP.UnableToBuildCollection(DbMetaDataCollectionNames.DataSourceInformation); } DataTable table = base.CloneAndFilterCollection(DbMetaDataCollectionNames.DataSourceInformation, null); if (table.Rows.Count != 1) { throw ADP.IncorrectNumberOfDataSourceInformationRows(); } DataRow row = table.Rows[0]; string literalInfo = internalConnection.GetLiteralInfo(3); string unescapedString = internalConnection.GetLiteralInfo(0x1b); if (literalInfo != null) { StringBuilder builder3 = new StringBuilder(); StringBuilder escapedString = new StringBuilder(); ADP.EscapeSpecialCharacters(literalInfo, escapedString); builder3.Append(escapedString.ToString()); if ((unescapedString != null) && (unescapedString != literalInfo)) { builder3.Append("|"); escapedString.Length = 0; ADP.EscapeSpecialCharacters(unescapedString, escapedString); builder3.Append(escapedString.ToString()); } row[DbMetaDataColumnNames.CompositeIdentifierSeparatorPattern] = builder3.ToString(); } else if (unescapedString != null) { StringBuilder builder4 = new StringBuilder(); ADP.EscapeSpecialCharacters(unescapedString, builder4); row[DbMetaDataColumnNames.CompositeIdentifierSeparatorPattern] = builder4.ToString(); } object dataSourcePropertyValue = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo, 40); if (dataSourcePropertyValue != null) { row[DbMetaDataColumnNames.DataSourceProductName] = (string)dataSourcePropertyValue; } row[DbMetaDataColumnNames.DataSourceProductVersion] = base.ServerVersion; row[DbMetaDataColumnNames.DataSourceProductVersionNormalized] = base.ServerVersionNormalized; row[DbMetaDataColumnNames.ParameterMarkerFormat] = "?"; row[DbMetaDataColumnNames.ParameterMarkerPattern] = @"\?"; row[DbMetaDataColumnNames.ParameterNameMaxLength] = 0; dataSourcePropertyValue = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo, 0x2c); GroupByBehavior unknown = GroupByBehavior.Unknown; if (dataSourcePropertyValue != null) { switch (((int)dataSourcePropertyValue)) { case 1: unknown = GroupByBehavior.NotSupported; break; case 2: unknown = GroupByBehavior.ExactMatch; break; case 4: unknown = GroupByBehavior.MustContainAll; break; case 8: unknown = GroupByBehavior.Unrelated; break; } } row[DbMetaDataColumnNames.GroupByBehavior] = unknown; this.SetIdentifierCase(DbMetaDataColumnNames.IdentifierCase, 0x2e, row, connection); this.SetIdentifierCase(DbMetaDataColumnNames.QuotedIdentifierCase, 100, row, connection); dataSourcePropertyValue = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo, 0x55); if (dataSourcePropertyValue != null) { row[DbMetaDataColumnNames.OrderByColumnsInSelect] = (bool)dataSourcePropertyValue; } DataTable table2 = internalConnection.BuildInfoLiterals(); if (table2 != null) { DataRow[] rowArray = table2.Select("Literal = " + 0x11.ToString(CultureInfo.InvariantCulture)); if (rowArray != null) { object obj4 = rowArray[0]["InvalidChars"]; if (obj4.GetType() == typeof(string)) { string str6; string invalidChars = (string)obj4; object obj3 = rowArray[0]["InvalidStartingChars"]; if (obj3.GetType() == typeof(string)) { str6 = (string)obj3; } else { str6 = invalidChars; } row[DbMetaDataColumnNames.IdentifierPattern] = this.BuildRegularExpression(invalidChars, str6); } } } connection.GetLiteralQuotes("GetSchema", out str4, out str3); if (str4 != null) { if (str3 == null) { str3 = str4; } if (str3.Length == 1) { StringBuilder builder = new StringBuilder(); ADP.EscapeSpecialCharacters(str3, builder); string str2 = builder.ToString(); builder.Length = 0; ADP.EscapeSpecialCharacters(str4, builder); builder.Append("(([^"); builder.Append(str2); builder.Append("]|"); builder.Append(str2); builder.Append(str2); builder.Append(")*)"); builder.Append(str2); row[DbMetaDataColumnNames.QuotedIdentifierPattern] = builder.ToString(); } } table.AcceptChanges(); return(table); }
public string UnquoteIdentifier(string quotedIdentifier, OleDbConnection 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 OleDbConnection; if (connection == null) { throw ADP.QuotePrefixNotSet(ADP.UnquoteIdentifier); } } connection.GetLiteralQuotes(ADP.UnquoteIdentifier, 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; } } String unquotedIdentifier; // 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); return unquotedIdentifier; }
// known difference: when getting the parameters for a sproc, the // return value gets marked as a return value but for a sql stmt // the return value gets marked as an output parameter. static private OleDbParameter[] DeriveParametersFromStoredProcedure(OleDbConnection connection, OleDbCommand command) { OleDbParameter[] plist = new OleDbParameter[0]; if (connection.SupportSchemaRowset(OleDbSchemaGuid.Procedure_Parameters)) { string quotePrefix, quoteSuffix; connection.GetLiteralQuotes(ADP.DeriveParameters, out quotePrefix, out quoteSuffix); Object[] parsed = MultipartIdentifier.ParseMultipartIdentifier(command.CommandText, quotePrefix, quoteSuffix, '.', 4, true, Res.OLEDB_OLEDBCommandText, false); // MDAC 70930 if (null == parsed[3]) { throw ADP.NoStoredProcedureExists(command.CommandText); } Object[] restrictions = new object[4]; object value; // Parse returns an enforced 4 part array // 0) Server - ignored but removal would be a run-time breaking change from V1.0 // 1) Catalog // 2) Schema // 3) ProcedureName // Restrictions array which is passed to OleDb API expects: // 0) Catalog // 1) Schema // 2) ProcedureName // 3) ParameterName (leave null) // Copy from Parse format to OleDb API format Array.Copy(parsed, 1, restrictions, 0, 3); //if (cmdConnection.IsServer_msdaora) { // restrictions[1] = Convert.ToString(cmdConnection.UserId).ToUpper(); //} DataTable table = connection.GetSchemaRowset(OleDbSchemaGuid.Procedure_Parameters, restrictions); if (null != table) { DataColumnCollection columns = table.Columns; DataColumn parameterName = null; DataColumn parameterDirection = null; DataColumn dataType = null; DataColumn maxLen = null; DataColumn numericPrecision = null; DataColumn numericScale = null; DataColumn backendtype = null; int index = columns.IndexOf(ODB.PARAMETER_NAME); if (-1 != index) parameterName = columns[index]; index = columns.IndexOf(ODB.PARAMETER_TYPE); if (-1 != index) parameterDirection = columns[index]; index = columns.IndexOf(ODB.DATA_TYPE); if (-1 != index) dataType = columns[index]; index = columns.IndexOf(ODB.CHARACTER_MAXIMUM_LENGTH); if (-1 != index) maxLen = columns[index]; index = columns.IndexOf(ODB.NUMERIC_PRECISION); if (-1 != index) numericPrecision = columns[index]; index = columns.IndexOf(ODB.NUMERIC_SCALE); if (-1 != index) numericScale = columns[index]; index = columns.IndexOf(ODB.TYPE_NAME); // MDAC 72315 if (-1 != index) backendtype = columns[index]; DataRow[] dataRows = table.Select(null, ODB.ORDINAL_POSITION_ASC, DataViewRowState.CurrentRows); // MDAC 70928 plist = new OleDbParameter[dataRows.Length]; for(index = 0; index < dataRows.Length; ++index) { DataRow dataRow = dataRows[index]; OleDbParameter parameter = new OleDbParameter(); if ((null != parameterName) && !dataRow.IsNull(parameterName, DataRowVersion.Default)) { // $ parameter.ParameterName = Convert.ToString(dataRow[parameterName, DataRowVersion.Default], CultureInfo.InvariantCulture).TrimStart(new char[] { '@', ' ', ':'}); } if ((null != parameterDirection) && !dataRow.IsNull(parameterDirection, DataRowVersion.Default)) { short direction = Convert.ToInt16(dataRow[parameterDirection, DataRowVersion.Default], CultureInfo.InvariantCulture); parameter.Direction = ConvertToParameterDirection(direction); } if ((null != dataType) && !dataRow.IsNull(dataType, DataRowVersion.Default)) { // need to ping FromDBType, otherwise WChar->WChar when the user really wants VarWChar short wType = Convert.ToInt16(dataRow[dataType, DataRowVersion.Default], CultureInfo.InvariantCulture); parameter.OleDbType = NativeDBType.FromDBType(wType, false, false).enumOleDbType; } if ((null != maxLen) && !dataRow.IsNull(maxLen, DataRowVersion.Default)) { parameter.Size = Convert.ToInt32(dataRow[maxLen, DataRowVersion.Default], CultureInfo.InvariantCulture); } switch(parameter.OleDbType) { case OleDbType.Decimal: case OleDbType.Numeric: case OleDbType.VarNumeric: if ((null != numericPrecision) && !dataRow.IsNull(numericPrecision, DataRowVersion.Default)) { // @devnote: unguarded cast from Int16 to Byte parameter.PrecisionInternal = (Byte) Convert.ToInt16(dataRow[numericPrecision], CultureInfo.InvariantCulture); } if ((null != numericScale) && !dataRow.IsNull(numericScale, DataRowVersion.Default)) { // @devnote: unguarded cast from Int16 to Byte parameter.ScaleInternal = (Byte) Convert.ToInt16(dataRow[numericScale], CultureInfo.InvariantCulture); } break; case OleDbType.VarBinary: // MDAC 72315 case OleDbType.VarChar: case OleDbType.VarWChar: value = dataRow[backendtype, DataRowVersion.Default]; if (value is string) { string backendtypename = ((string) value).ToLower(CultureInfo.InvariantCulture); switch(backendtypename) { case "binary": parameter.OleDbType = OleDbType.Binary; break; //case "varbinary": // parameter.OleDbType = OleDbType.VarBinary; // break; case "image": parameter.OleDbType = OleDbType.LongVarBinary; break; case "char": parameter.OleDbType = OleDbType.Char; break; //case "varchar": //case "varchar2": // parameter.OleDbType = OleDbType.VarChar; // break; case "text": parameter.OleDbType = OleDbType.LongVarChar; break; case "nchar": parameter.OleDbType = OleDbType.WChar; break; //case "nvarchar": // parameter.OleDbType = OleDbType.VarWChar; case "ntext": parameter.OleDbType = OleDbType.LongVarWChar; break; } } break; } //if (AdapterSwitches.OleDbSql.TraceVerbose) { // ADP.Trace_Parameter("StoredProcedure", parameter); //} plist[index] = parameter; } } if ((0 == plist.Length) && connection.SupportSchemaRowset(OleDbSchemaGuid.Procedures)) { restrictions = new Object[4] { null, null, command.CommandText, null}; table = connection.GetSchemaRowset(OleDbSchemaGuid.Procedures, restrictions); if (0 == table.Rows.Count) { throw ADP.NoStoredProcedureExists(command.CommandText); } } } else if (connection.SupportSchemaRowset(OleDbSchemaGuid.Procedures)) { Object[] restrictions = new Object[4] { null, null, command.CommandText, null}; DataTable table = connection.GetSchemaRowset(OleDbSchemaGuid.Procedures, restrictions); if (0 == table.Rows.Count) { throw ADP.NoStoredProcedureExists(command.CommandText); } // we don't ever expect a procedure with 0 parameters, they should have at least a return value throw ODB.NoProviderSupportForSProcResetParameters(connection.Provider); // MDAC 71968 } else { throw ODB.NoProviderSupportForSProcResetParameters(connection.Provider); // MDAC 70918 } return plist; }
private DataTable GetDataSourceInformationTable(OleDbConnection connection, OleDbConnectionInternal internalConnection){ // verify that the data source information table is in the data set DataTable dataSourceInformationTable = CollectionDataSet.Tables[DbMetaDataCollectionNames.DataSourceInformation]; if (dataSourceInformationTable == null){ throw ADP.UnableToBuildCollection(DbMetaDataCollectionNames.DataSourceInformation); } // copy the table filtering out any rows that don't apply to tho current version of the prrovider dataSourceInformationTable = CloneAndFilterCollection(DbMetaDataCollectionNames.DataSourceInformation, null); // after filtering there better be just one row if (dataSourceInformationTable.Rows.Count != 1){ throw ADP.IncorrectNumberOfDataSourceInformationRows(); } DataRow dataSourceInformation = dataSourceInformationTable.Rows[0]; // update the identifier separator string catalogSeparatorPattern = internalConnection.GetLiteralInfo(ODB.DBLITERAL_CATALOG_SEPARATOR); string schemaSeparatorPattern = internalConnection.GetLiteralInfo(ODB.DBLITERAL_SCHEMA_SEPARATOR); if (catalogSeparatorPattern != null) { StringBuilder compositeSeparatorPattern = new StringBuilder(); StringBuilder patternEscaped = new StringBuilder(); ADP.EscapeSpecialCharacters(catalogSeparatorPattern,patternEscaped); compositeSeparatorPattern.Append(patternEscaped.ToString()); if ((schemaSeparatorPattern != null) && (schemaSeparatorPattern != catalogSeparatorPattern)) { compositeSeparatorPattern.Append("|"); patternEscaped.Length = 0; ADP.EscapeSpecialCharacters(schemaSeparatorPattern,patternEscaped); compositeSeparatorPattern.Append(patternEscaped.ToString()); } dataSourceInformation[DbMetaDataColumnNames.CompositeIdentifierSeparatorPattern] = compositeSeparatorPattern.ToString(); } else if (schemaSeparatorPattern != null){ StringBuilder patternEscaped = new StringBuilder(); ADP.EscapeSpecialCharacters(schemaSeparatorPattern, patternEscaped); dataSourceInformation[DbMetaDataColumnNames.CompositeIdentifierSeparatorPattern] = patternEscaped.ToString();; } // update the DataSourceProductName object property; property = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo,ODB.DBPROP_DBMSNAME); if (property != null) { dataSourceInformation[DbMetaDataColumnNames.DataSourceProductName] = (string) property; } // update the server version strings dataSourceInformation[DbMetaDataColumnNames.DataSourceProductVersion] = ServerVersion; dataSourceInformation[DbMetaDataColumnNames.DataSourceProductVersionNormalized] = ServerVersionNormalized; // values that are the same for all OLE DB Providers. See SQLBU 308529 dataSourceInformation[DbMetaDataColumnNames.ParameterMarkerFormat] = "?"; dataSourceInformation[DbMetaDataColumnNames.ParameterMarkerPattern] = "\\?"; dataSourceInformation[DbMetaDataColumnNames.ParameterNameMaxLength] = 0; property = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo,ODB.DBPROP_GROUPBY); GroupByBehavior groupByBehavior = GroupByBehavior.Unknown; if (property != null) { switch ((int)property) { case ODB.DBPROPVAL_GB_CONTAINS_SELECT: groupByBehavior = GroupByBehavior.MustContainAll; break; case ODB.DBPROPVAL_GB_EQUALS_SELECT: groupByBehavior = GroupByBehavior.ExactMatch; break; case ODB.DBPROPVAL_GB_NO_RELATION: groupByBehavior = GroupByBehavior.Unrelated; break; case ODB.DBPROPVAL_GB_NOT_SUPPORTED: groupByBehavior = GroupByBehavior.NotSupported; break; } } dataSourceInformation[DbMetaDataColumnNames.GroupByBehavior] = groupByBehavior; SetIdentifierCase(DbMetaDataColumnNames.IdentifierCase,ODB.DBPROP_IDENTIFIERCASE,dataSourceInformation, connection); SetIdentifierCase(DbMetaDataColumnNames.QuotedIdentifierCase,ODB.DBPROP_QUOTEDIDENTIFIERCASE,dataSourceInformation, connection); property = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo,ODB.DBPROP_ORDERBYCOLUNSINSELECT); if (property != null) { dataSourceInformation[DbMetaDataColumnNames.OrderByColumnsInSelect] = (bool) property; } DataTable infoLiterals = internalConnection.BuildInfoLiterals(); if (infoLiterals != null){ DataRow[] tableNameRow = infoLiterals.Select("Literal = " + ODB.DBLITERAL_TABLE_NAME.ToString(CultureInfo.InvariantCulture)); if (tableNameRow != null) { object invalidCharsObject = tableNameRow[0]["InvalidChars"]; if (invalidCharsObject.GetType() == typeof(string)) { string invalidChars = (string)invalidCharsObject; object invalidStartingCharsObject = tableNameRow[0]["InvalidStartingChars"]; string invalidStartingChars; if (invalidStartingCharsObject.GetType() == typeof(string)) { invalidStartingChars = (string)invalidStartingCharsObject; } else { invalidStartingChars = invalidChars; } dataSourceInformation[DbMetaDataColumnNames.IdentifierPattern] = BuildRegularExpression(invalidChars,invalidStartingChars); } } } // 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 "") string quotePrefix; string quoteSuffix; connection.GetLiteralQuotes(ADP.GetSchema, out quotePrefix, out quoteSuffix); if (quotePrefix != null){ // 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; } // only know how to build the parttern if the suffix is 1 character // in all other cases just leave the field null if (quoteSuffix.Length == 1) { StringBuilder scratchStringBuilder = new StringBuilder(); ADP.EscapeSpecialCharacters(quoteSuffix,scratchStringBuilder ); string escapedQuoteSuffixString = scratchStringBuilder.ToString(); scratchStringBuilder.Length = 0; ADP.EscapeSpecialCharacters(quotePrefix, scratchStringBuilder); scratchStringBuilder.Append("(([^"); scratchStringBuilder.Append(escapedQuoteSuffixString); scratchStringBuilder.Append("]|"); scratchStringBuilder.Append(escapedQuoteSuffixString); scratchStringBuilder.Append(escapedQuoteSuffixString); scratchStringBuilder.Append(")*)"); scratchStringBuilder.Append(escapedQuoteSuffixString); dataSourceInformation[DbMetaDataColumnNames.QuotedIdentifierPattern] = scratchStringBuilder.ToString(); } } dataSourceInformationTable.AcceptChanges(); return dataSourceInformationTable; }