DbException Constructors

Definition

Initializes a new instance of the DbException class.

Overloads

DbException()

Initializes a new instance of the DbException class.

DbException(String)

Initializes a new instance of the DbException class with the specified error message.

DbException(SerializationInfo, StreamingContext)
Obsolete.

Initializes a new instance of the DbException class with the specified serialization information and context.

DbException(String, Exception)

Initializes a new instance of the DbException class with the specified error message and a reference to the inner exception that is the cause of this exception.

DbException(String, Int32)

Initializes a new instance of the DbException class with the specified error message and error code.

Remarks

The DbException class is an abstract class used as the base class for provider-specific exception class implementations.

DbException()

Source:
DbException.cs
Source:
DbException.cs
Source:
DbException.cs

Initializes a new instance of the DbException class.

C#
protected DbException();

Remarks

The DbException class is an abstract class used as the base class for provider-specific exception class implementations.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

DbException(String)

Source:
DbException.cs
Source:
DbException.cs
Source:
DbException.cs

Initializes a new instance of the DbException class with the specified error message.

C#
protected DbException(string message);
C#
protected DbException(string? message);

Parameters

message
String

The message to display for this exception.

Remarks

The DbException class is an abstract class used as the base class for provider-specific exception class implementations.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

DbException(SerializationInfo, StreamingContext)

Source:
DbException.cs
Source:
DbException.cs
Source:
DbException.cs

Caution

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Initializes a new instance of the DbException class with the specified serialization information and context.

C#
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected DbException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
C#
protected DbException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);

Parameters

info
SerializationInfo

The SerializationInfo that holds the serialized object data about the exception being thrown.

context
StreamingContext

The StreamingContext that contains contextual information about the source or destination.

Attributes

Remarks

The DbException class is an abstract class used as the base class for provider-specific exception class implementations.

See also

Applies to

.NET 10 and other versions
Product Versions (Obsolete)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7 (8, 9, 10)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

DbException(String, Exception)

Source:
DbException.cs
Source:
DbException.cs
Source:
DbException.cs

Initializes a new instance of the DbException class with the specified error message and a reference to the inner exception that is the cause of this exception.

C#
protected DbException(string message, Exception innerException);
C#
protected DbException(string? message, Exception? innerException);

Parameters

message
String

The error message string.

innerException
Exception

The inner exception reference.

Remarks

The DbException class is an abstract class used as the base class for provider-specific exception class implementations.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

DbException(String, Int32)

Source:
DbException.cs
Source:
DbException.cs
Source:
DbException.cs

Initializes a new instance of the DbException class with the specified error message and error code.

C#
protected DbException(string? message, int errorCode);
C#
protected DbException(string message, int errorCode);

Parameters

message
String

The error message that explains the reason for the exception.

errorCode
Int32

The error code for the exception.

Remarks

The DbException class is an abstract class used as the base class for provider-specific exception class implementations.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1