OleDbException Sınıf
Tanım
Temel sağlayıcı bir OLE DB veri kaynağı için bir uyarı veya hata döndürdüğünde oluşturulan özel durum.The exception that is thrown when the underlying provider returns a warning or error for an OLE DB data source. Bu sınıf devralınamaz.This class cannot be inherited.
public ref class OleDbException sealed : System::Data::Common::DbException
public ref class OleDbException sealed : System::Runtime::InteropServices::ExternalException
public sealed class OleDbException : System.Data.Common.DbException
[System.Serializable]
public sealed class OleDbException : System.Runtime.InteropServices.ExternalException
[System.Serializable]
public sealed class OleDbException : System.Data.Common.DbException
type OleDbException = class
inherit DbException
[<System.Serializable>]
type OleDbException = class
inherit ExternalException
[<System.Serializable>]
type OleDbException = class
inherit DbException
Public NotInheritable Class OleDbException
Inherits DbException
Public NotInheritable Class OleDbException
Inherits ExternalException
- Devralma
- Devralma
- Devralma
- Öznitelikler
Örnekler
Aşağıdaki örnek, bir OleDbException eksik veri kaynağı nedeniyle bir hata oluşturur ve özel durumu görüntüler.The following example generates an OleDbException because of a missing data source, and then displays the exception.
public void ShowOleDbException()
{
string mySelectQuery = "SELECT column1 FROM table1";
OleDbConnection myConnection =
new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=");
OleDbCommand myCommand = new OleDbCommand(mySelectQuery,myConnection);
try
{
myCommand.Connection.Open();
}
catch (OleDbException e)
{
string errorMessages = "";
for (int i=0; i < e.Errors.Count; i++)
{
errorMessages += "Index #" + i + "\n" +
"Message: " + e.Errors[i].Message + "\n" +
"NativeError: " + e.Errors[i].NativeError + "\n" +
"Source: " + e.Errors[i].Source + "\n" +
"SQLState: " + e.Errors[i].SQLState + "\n";
}
System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
log.Source = "My Application";
log.WriteEntry(errorMessages);
Console.WriteLine("An exception occurred. Please contact your system administrator.");
}
}
Public Sub ShowOleDbException()
Dim mySelectQuery As String = "SELECT column1 FROM table1"
Dim myConnection As New OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=")
Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)
Try
myCommand.Connection.Open()
Catch e As OleDbException
Dim errorMessages As String
Dim i As Integer
For i = 0 To e.Errors.Count - 1
errorMessages += "Index #" & i.ToString() & ControlChars.Cr _
& "Message: " & e.Errors(i).Message & ControlChars.Cr _
& "NativeError: " & e.Errors(i).NativeError & ControlChars.Cr _
& "Source: " & e.Errors(i).Source & ControlChars.Cr _
& "SQLState: " & e.Errors(i).SQLState & ControlChars.Cr
Next i
Dim log As New System.Diagnostics.EventLog()
log.Source = "My Application"
log.WriteEntry(errorMessages)
Console.WriteLine("An exception occurred. Please contact your system administrator.")
End Try
End Sub
Açıklamalar
Bu sınıf, OLE DB için .NET Framework Veri Sağlayıcısı sunucudan oluşturulan bir hatayla karşılaştığında oluşturulur.This class is created whenever the .NET Framework Data Provider for OLE DB encounters an error generated from the server. (İstemci tarafı hataları standart ortak dil çalışma zamanı özel durumları olarak oluşturulur.) OleDbException her zaman en az bir örneği içerir OleDbError .(Client side errors are thrown as standard common language runtime exceptions.) OleDbException always contains at least one instance of OleDbError.
Hatanın önem derecesi çok harika ise, sunucu kapatılabilir OleDbConnection .If the severity of the error is too great, the server may close the OleDbConnection. Ancak, Kullanıcı bağlantıyı yeniden açabilir ve devam edebilir.However, the user can reopen the connection and continue.
.NET Framework veri sağlayıcısı için özel durumları işleme hakkında genel bilgi için bkz SqlException ..For general information about handling exceptions for a .NET Framework data provider, see SqlException.
Özellikler
Data |
Özel durum hakkında ek kullanıcı tanımlı bilgiler sağlayan anahtar/değer çiftleri koleksiyonunu alır.Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Devralındığı yer: Exception) |
ErrorCode |
Hatanın HRESULT 'yi alır.Gets the HRESULT of the error. |
Errors |
OleDbErrorOLE DB için .NET Framework veri sağlayıcısı tarafından oluşturulan özel durumlarla ilgili ayrıntılı bilgi veren bir veya daha fazla nesnenin koleksiyonunu alır.Gets a collection of one or more OleDbError objects that give detailed information about exceptions generated by the .NET Framework Data Provider for OLE DB. |
HelpLink |
Bu özel durumla ilişkili Yardım dosyasının bağlantısını alır veya ayarlar.Gets or sets a link to the help file associated with this exception. (Devralındığı yer: Exception) |
HResult |
Belirli bir özel duruma atanan kodlanmış bir sayısal değer olan HRESULT 'yi alır veya ayarlar.Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Devralındığı yer: Exception) |
InnerException |
ExceptionGeçerli özel duruma neden olan örneği alır.Gets the Exception instance that caused the current exception. (Devralındığı yer: Exception) |
IsTransient |
Bu tarafından temsil edilen hatanın DbException geçici bir hata olup olmadığını, yani tetikleme işleminin yeniden denenmesinin başka hiçbir değişiklik yapılmadan başarılı olabileceğini gösterir.Indicates whether the error represented by this DbException could be a transient error, i.e. if retrying the triggering operation may succeed without any other change. (Devralındığı yer: DbException) |
Message |
Hatayı açıklayan metni alır.Gets the text describing the error. |
Message |
Geçerli özel durumu açıklayan bir ileti alır.Gets a message that describes the current exception. (Devralındığı yer: Exception) |
Source |
Hatayı oluşturan OLE DB sağlayıcının adını alır.Gets the name of the OLE DB provider that generated the error. |
Source |
Uygulamanın veya hataya neden olan nesnenin adını alır veya ayarlar.Gets or sets the name of the application or the object that causes the error. (Devralındığı yer: Exception) |
SqlState |
Bunu destekleyen veritabanı sağlayıcıları için, veritabanı işleminin başarısını veya başarısızlığını belirten standart bir SQL 5 karakterlik dönüş kodu içerir.For database providers which support it, contains a standard SQL 5-character return code indicating the success or failure of the database operation. İlk 2 karakter dönüş kodu sınıfını temsil eder (örn. hata, başarı), son 3 karakter alt sınıfınıtemsil ederken, veritabanı taşınabilir bir şekilde hata senaryolarını algılamaya izin verir.The first 2 characters represent the class of the return code (e.g. error, success), while the last 3 characters represent the subclass, allowing detection of error scenarios in a database-portable way. Bunu desteklemeyen veritabanı sağlayıcıları veya uygulanabilir hata senaryoları için, içerir |
StackTrace |
Çağrı yığınında anlık çerçevelerin dize gösterimini alır.Gets a string representation of the immediate frames on the call stack. (Devralındığı yer: Exception) |
TargetSite |
Geçerli özel durumu oluşturan yöntemi alır.Gets the method that throws the current exception. (Devralındığı yer: Exception) |
Yöntemler
Equals(Object) |
Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.Determines whether the specified object is equal to the current object. (Devralındığı yer: Object) |
GetBaseException() |
Türetilmiş bir sınıfta geçersiz kılınırsa, Exception bir veya daha fazla sonraki özel durumun kök nedeni olan öğesini döndürür.When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Devralındığı yer: Exception) |
GetHashCode() |
Varsayılan karma işlevi olarak işlev görür.Serves as the default hash function. (Devralındığı yer: Object) |
GetObjectData(SerializationInfo, StreamingContext) |
Bu üye geçersiz kılınır GetObjectData(SerializationInfo, StreamingContext) .This member overrides GetObjectData(SerializationInfo, StreamingContext). |
GetType() |
Geçerli örneğin çalışma zamanı türünü alır.Gets the runtime type of the current instance. (Devralındığı yer: Exception) |
MemberwiseClone() |
Geçerli bir basit kopyasını oluşturur Object .Creates a shallow copy of the current Object. (Devralındığı yer: Object) |
ToString() |
Geçerli özel durumun dize gösterimini oluşturur ve döndürür.Creates and returns a string representation of the current exception. (Devralındığı yer: Exception) |
ToString() |
Hatanın HRESULT değerini içeren bir dize döndürür.Returns a string that contains the HRESULT of the error. (Devralındığı yer: ExternalException) |
Ekinlikler
SerializeObjectState |
Özel durum hakkında serileştirilmiş veri içeren bir özel durum nesnesi oluşturmak için bir özel durum serileştirildiğinde gerçekleşir.Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception. (Devralındığı yer: Exception) |