Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Data / System / Data / OleDb / OleDbError.cs / 1 / OleDbError.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
//-----------------------------------------------------------------------------
namespace System.Data.OleDb {
using System;
using System.Data.Common;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
[Serializable]
#if WINFSInternalOnly
internal
#else
public
#endif
sealed class OleDbError {
readonly private string message;
readonly private string source;
readonly private string sqlState;
readonly private int nativeError;
internal OleDbError(UnsafeNativeMethods.IErrorRecords errorRecords, int index) {
OleDbHResult hr;
int lcid = System.Globalization.CultureInfo.CurrentCulture.LCID;
Bid.Trace("\n");
UnsafeNativeMethods.IErrorInfo errorInfo = errorRecords.GetErrorInfo(index, lcid);
if (null != errorInfo) {
Bid.Trace("\n");
hr = errorInfo.GetDescription(out this.message);
Bid.Trace(" Message='%ls'\n", this.message);
if (OleDbHResult.DB_E_NOLOCALE == hr) { // MDAC 87303
Bid.Trace(" ErrorInfo\n");
Marshal.ReleaseComObject(errorInfo);
Bid.Trace("\n");
lcid = SafeNativeMethods.GetUserDefaultLCID();
Bid.Trace(" LCID=%d\n", lcid);
errorInfo = errorRecords.GetErrorInfo(index, lcid);
if (null != errorInfo) {
Bid.Trace("\n");
hr = errorInfo.GetDescription(out this.message);
Bid.Trace(" Message='%ls'\n", this.message);
}
}
if ((hr < 0) && ADP.IsEmpty(this.message)) {
this.message = ODB.FailedGetDescription(hr);
}
if (null != errorInfo) {
Bid.Trace("\n");
hr = errorInfo.GetSource(out this.source);
Bid.Trace(" Source='%ls'\n", this.source);
if (OleDbHResult.DB_E_NOLOCALE == hr) { // MDAC 87303
Marshal.ReleaseComObject(errorInfo);
Bid.Trace("\n");
lcid = SafeNativeMethods.GetUserDefaultLCID();
Bid.Trace(" LCID=%d\n", lcid);
errorInfo = errorRecords.GetErrorInfo(index, lcid);
if (null != errorInfo) {
Bid.Trace("\n");
hr = errorInfo.GetSource(out this.source);
Bid.Trace(" Source='%ls'\n", this.source);
}
}
if ((hr < 0) && ADP.IsEmpty(this.source)) {
this.source = ODB.FailedGetSource(hr);
}
Bid.Trace(" ErrorInfo\n");
Marshal.ReleaseComObject(errorInfo);
}
}
UnsafeNativeMethods.ISQLErrorInfo sqlErrorInfo;
Bid.Trace(" IID_ISQLErrorInfo\n");
hr = errorRecords.GetCustomErrorObject(index, ref ODB.IID_ISQLErrorInfo, out sqlErrorInfo);
if (null != sqlErrorInfo) {
Bid.Trace("\n");
this.nativeError = sqlErrorInfo.GetSQLInfo(out this.sqlState);
Bid.Trace(" SQLErrorInfo\n");
Marshal.ReleaseComObject(sqlErrorInfo);
}
}
public string Message {
get {
string message = this.message;
return ((null != message) ? message : ADP.StrEmpty);
}
}
public int NativeError {
get {
return this.nativeError;
}
}
public string Source {
get {
string source = this.source;
return ((null != source) ? source : ADP.StrEmpty);
}
}
public string SQLState {
get {
string sqlState = this.sqlState;
return ((null != sqlState) ? sqlState : ADP.StrEmpty);
}
}
override public string ToString() {
return Message;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
//-----------------------------------------------------------------------------
namespace System.Data.OleDb {
using System;
using System.Data.Common;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
[Serializable]
#if WINFSInternalOnly
internal
#else
public
#endif
sealed class OleDbError {
readonly private string message;
readonly private string source;
readonly private string sqlState;
readonly private int nativeError;
internal OleDbError(UnsafeNativeMethods.IErrorRecords errorRecords, int index) {
OleDbHResult hr;
int lcid = System.Globalization.CultureInfo.CurrentCulture.LCID;
Bid.Trace("\n");
UnsafeNativeMethods.IErrorInfo errorInfo = errorRecords.GetErrorInfo(index, lcid);
if (null != errorInfo) {
Bid.Trace("\n");
hr = errorInfo.GetDescription(out this.message);
Bid.Trace(" Message='%ls'\n", this.message);
if (OleDbHResult.DB_E_NOLOCALE == hr) { // MDAC 87303
Bid.Trace(" ErrorInfo\n");
Marshal.ReleaseComObject(errorInfo);
Bid.Trace("\n");
lcid = SafeNativeMethods.GetUserDefaultLCID();
Bid.Trace(" LCID=%d\n", lcid);
errorInfo = errorRecords.GetErrorInfo(index, lcid);
if (null != errorInfo) {
Bid.Trace("\n");
hr = errorInfo.GetDescription(out this.message);
Bid.Trace(" Message='%ls'\n", this.message);
}
}
if ((hr < 0) && ADP.IsEmpty(this.message)) {
this.message = ODB.FailedGetDescription(hr);
}
if (null != errorInfo) {
Bid.Trace("\n");
hr = errorInfo.GetSource(out this.source);
Bid.Trace(" Source='%ls'\n", this.source);
if (OleDbHResult.DB_E_NOLOCALE == hr) { // MDAC 87303
Marshal.ReleaseComObject(errorInfo);
Bid.Trace("\n");
lcid = SafeNativeMethods.GetUserDefaultLCID();
Bid.Trace(" LCID=%d\n", lcid);
errorInfo = errorRecords.GetErrorInfo(index, lcid);
if (null != errorInfo) {
Bid.Trace("\n");
hr = errorInfo.GetSource(out this.source);
Bid.Trace(" Source='%ls'\n", this.source);
}
}
if ((hr < 0) && ADP.IsEmpty(this.source)) {
this.source = ODB.FailedGetSource(hr);
}
Bid.Trace(" ErrorInfo\n");
Marshal.ReleaseComObject(errorInfo);
}
}
UnsafeNativeMethods.ISQLErrorInfo sqlErrorInfo;
Bid.Trace(" IID_ISQLErrorInfo\n");
hr = errorRecords.GetCustomErrorObject(index, ref ODB.IID_ISQLErrorInfo, out sqlErrorInfo);
if (null != sqlErrorInfo) {
Bid.Trace("\n");
this.nativeError = sqlErrorInfo.GetSQLInfo(out this.sqlState);
Bid.Trace(" SQLErrorInfo\n");
Marshal.ReleaseComObject(sqlErrorInfo);
}
}
public string Message {
get {
string message = this.message;
return ((null != message) ? message : ADP.StrEmpty);
}
}
public int NativeError {
get {
return this.nativeError;
}
}
public string Source {
get {
string source = this.source;
return ((null != source) ? source : ADP.StrEmpty);
}
}
public string SQLState {
get {
string sqlState = this.sqlState;
return ((null != sqlState) ? sqlState : ADP.StrEmpty);
}
}
override public string ToString() {
return Message;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BuilderInfo.cs
- SqlError.cs
- DataTemplateKey.cs
- SchemaImporterExtension.cs
- AnnotationHelper.cs
- DataStreamFromComStream.cs
- WorkflowRuntimeServicesBehavior.cs
- Constraint.cs
- WebPartUserCapability.cs
- PathNode.cs
- ConsumerConnectionPointCollection.cs
- validation.cs
- KeyboardNavigation.cs
- CommandDevice.cs
- RegexCapture.cs
- LogSwitch.cs
- QilFactory.cs
- QueryReaderSettings.cs
- GZipStream.cs
- SynthesizerStateChangedEventArgs.cs
- UserControlCodeDomTreeGenerator.cs
- BitmapSource.cs
- ObjectDataSourceDisposingEventArgs.cs
- DataSourceDesigner.cs
- PermissionAttributes.cs
- _HelperAsyncResults.cs
- WebPartConnection.cs
- FlowDocumentScrollViewer.cs
- DesignerActionService.cs
- RoleExceptions.cs
- TableChangeProcessor.cs
- WindowsRichEdit.cs
- FontStretchConverter.cs
- TimeManager.cs
- DataGridViewDataErrorEventArgs.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- WeakReference.cs
- WebPartActionVerb.cs
- ProfessionalColors.cs
- DocumentApplicationDocumentViewer.cs
- TemplateManager.cs
- SoapSchemaMember.cs
- CheckBoxStandardAdapter.cs
- LocalizeDesigner.cs
- EntityTemplateUserControl.cs
- precedingsibling.cs
- FamilyMapCollection.cs
- safelinkcollection.cs
- DockAndAnchorLayout.cs
- GroupBox.cs
- ExceptionUtil.cs
- TextEditorLists.cs
- TextRangeEditTables.cs
- OnOperation.cs
- FixedSOMTextRun.cs
- sortedlist.cs
- COM2EnumConverter.cs
- SqlGenericUtil.cs
- Permission.cs
- URLAttribute.cs
- SynchronizedInputAdaptor.cs
- HtmlTableRowCollection.cs
- ItemMap.cs
- WebSysDefaultValueAttribute.cs
- Membership.cs
- GeometryDrawing.cs
- WorkflowOperationErrorHandler.cs
- WebPartDescription.cs
- httpstaticobjectscollection.cs
- SecurityResources.cs
- SafeNativeMethods.cs
- PrinterUnitConvert.cs
- BevelBitmapEffect.cs
- HtmlHead.cs
- ListViewDeleteEventArgs.cs
- ColumnHeaderConverter.cs
- SchemaElementDecl.cs
- SiteMapSection.cs
- CompoundFileIOPermission.cs
- httpstaticobjectscollection.cs
- ByteStack.cs
- HtmlInputButton.cs
- ResourceWriter.cs
- CompareValidator.cs
- clipboard.cs
- DataListDesigner.cs
- PlatformCulture.cs
- HttpRequestCacheValidator.cs
- WebBrowserProgressChangedEventHandler.cs
- XmlSchema.cs
- SelectionItemProviderWrapper.cs
- EventMappingSettings.cs
- WebPartHelpVerb.cs
- X509SubjectKeyIdentifierClause.cs
- ObjectDataSourceMethodEventArgs.cs
- CharAnimationBase.cs
- SerializerDescriptor.cs
- CodeDelegateCreateExpression.cs
- COM2ExtendedTypeConverter.cs
- DesignParameter.cs