OdbcException Sınıf
Tanım
ODBC veri kaynağı tarafından bir uyarı veya hata döndürüldüğünde oluşturulan özel durum.The exception that is generated when a warning or error is returned by an ODBC data source. Bu sınıf devralınamaz.This class cannot be inherited.
public ref class OdbcException sealed : System::Data::Common::DbException
public ref class OdbcException sealed : SystemException
public sealed class OdbcException : System.Data.Common.DbException
[System.Serializable]
public sealed class OdbcException : SystemException
[System.Serializable]
public sealed class OdbcException : System.Data.Common.DbException
type OdbcException = class
inherit DbException
[<System.Serializable>]
type OdbcException = class
inherit SystemException
[<System.Serializable>]
type OdbcException = class
inherit DbException
Public NotInheritable Class OdbcException
Inherits DbException
Public NotInheritable Class OdbcException
Inherits SystemException
- Devralma
- Devralma
- Devralma
- Öznitelikler
Örnekler
Aşağıdaki örnek, bir OdbcException eksik veri kaynağı nedeniyle bir hata oluşturur ve özel durumu görüntüler.The following example generates an OdbcException because of a missing data source, and then displays the exception.
public void ShowOdbcException()
{
string mySelectQuery = "SELECT column1 FROM table1";
OdbcConnection myConnection =
new OdbcConnection("DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=northwind;");
OdbcCommand myCommand = new OdbcCommand(mySelectQuery,myConnection);
try
{
myCommand.Connection.Open();
}
catch (OdbcException 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.ToString() + "\n" +
"Source: " + e.Errors[i].Source + "\n" +
"SQL: " + 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 ShowOdbcException()
Dim mySelectQuery As String = "SELECT column1 FROM table1"
Dim myConnection As New OdbcConnection _
("DRIVER={SQL Server};SERVER=MyServer;Trusted_connection=yes;DATABASE=northwind;")
Dim myCommand As New OdbcCommand(mySelectQuery, myConnection)
Try
myCommand.Connection.Open()
Catch e As OdbcException
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.ToString() & ControlChars.Cr _
& "Source: " & e.Errors(i).Source & ControlChars.Cr _
& "SQL: " & 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, OdbcDataAdapter sunucu tarafından oluşturulan bir hatayla karşılaştığında oluşturulur (istemci tarafı hataları standart ortak dil çalışma zamanı özel durumları olarak tetiklenir.).This class is created whenever the OdbcDataAdapter encounters an error generated by the server (Client-side errors are raised as standard common language runtime exceptions.). Her zaman en az bir örneği içerir OdbcError .It always contains at least one instance of OdbcError.
Hatanın önem derecesi çok harika ise, sunucu kapatılabilir OdbcConnection .If the severity of the error is too great, the server may close the OdbcConnection. 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 |
Hatayı alır |
Errors |
OdbcErrorODBC 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 OdbcError objects that give detailed information about exceptions generated by the .NET Framework Data Provider for ODBC. |
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 |
Geçerli özel durumu açıklayan bir ileti alır.Gets a message that describes the current exception. |
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 ODBC sürücüsünün adını alır.Gets the name of the ODBC driver that generated the error. |
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) |