SQL Server Data Provider Classes
- Last Updated: April 16, 2026
- 14 minute read
- ADO.NET
- Documentation
The SQL Server data provider supports the public classes, properties, and methods as described in the Microsoft .NET Framework SDK documentation. The SQL Server data provider attaches the provider-specific prefix SQLServer to the public .NET class, for example, SQLServerCommand.
This section describes the provider-specific properties and methods of the SQL Server data provider.
SQLServerBulkCopy Class
The SQLServerBulkCopy class uses a model similar to the ADO.NET Bulk API patterns, and has no provider-specific properties or methods. For information about the properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
SQLServerBulkCopyColumnMapping Class
The SQLServerBulkCopyColumnMapping class uses an API pattern similar to the Microsoft SqlBulkCopyMapping class, and has no provider-specific properties or methods. For information about the properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
SQLServerBulkCopyColumnMappingCollection Class
The SQLServerBulkCopyColumnMapping class follows an API pattern similar to the Microsoft SqlBulkCopyColumnMappingCollection class, and has no provider-specific properties or methods. For information about the properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
SQLServerCommand Class
The following table lists the provider-specific public properties of the SQLServerCommand class. The table includes the generic public properties of the Command class when provider-specific information supplements the standard descriptions. For information about other properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
Public Properties of the SQLServerCommand Class
| Property | Description |
| ArrayBindCount | Specifies the number of rows of parameters that are used. The application must set this property before executing a command that uses parameter array binding. The count must equal the length of each of the arrays that is set for each parameter value. When set to 0 (the initial default), the application does not use parameter array binding. |
| ArrayBindStatus | Specifies the method the application uses to inspect the per row status after executing a command using parameter array binding. The property's type is an array of SQLServerRowStatus. Parameter arrays with SQL Server are sent as one batch of statements. The SQLServerRowStatus enumeration has the following possible values:
|
| CommandTimeout | Gets or sets the wait time before terminating the attempt to execute a command and generating an error. The initial default is 30 seconds. We recommend that the application sets the CommandTimeout property to a value that is greater than the largest default timeout value on the server. This ensures that the application gets a more meaningful reply in case of a timeout. |
| FetchBufferSize | Allows you to override the connection string option Fetch Buffer Size on a per-command basis. |
| RowSetSize | Limits the number of rows returned by any query executed on this Command class to the value specified at execution time. Valid values are 0 to 2147483647. When set to 0 (the initial default), the data provider does not limit the number of rows returned. |
| UpdatedRowSource | Gets or sets how command results are applied to the DataRow, when used by the Update method of a DbDataAdapter. When the UpdateBatchSize property is set to a value other than 1, UpdatedRowSource property for the UpdateCommand, DeleteCommand, and InsertCommand must be set to None or OutputParameters. When set to None, any returned parameters or rows are ignored. When set to OutputParameters, output parameters are mapped to the changed row in the DataSet. |
SQLServerCommandBuilder Class
Using a CommandBuilder class can have a negative effect on performance. Because of concurrency restrictions, the CommandBuilder can generate highly inefficient SQL statements. The end-user can often write more efficient update and delete statements than those that the CommandBuilder generates.
The SQLServerCommandBuilder class has no provider-specific properties or methods. For information about the properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
SQLServerConnection Class
The following table lists the provider-specific public constructors of the SQLServerConnection class.
Public Constructors of the SQLServerConnection Class
| Constructor | Description |
| SQLServerConnection() | Initializes a new instance of the SQLServerConnection class. |
| SQLServerConnection(string connectionString) | Initializes a new instance of the SQLServerConnection class when given a string that contains the connection string. |
| SQLServerConnection(string connectionString, SQLServerCredential credential) | Initializes a new instance of the SQLServerConnection class given a connection string and a SQLServerCredential object that contains the user ID and password. |
The following table lists the provider-specific public properties of the SQLServerConnection class. Some properties return the values specified for the corresponding connection string option. See Connection String Options for more information. For a description of other properties supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
Public Properties of the SQLServerConnection Class
| Property | Description |
| ApplicationName | Returns the value specified for the Application Name connection string option. Read-only. |
| CloneConnectionIfNeeded | Returns the value specified for the Clone Connection If Needed connection string option. Read-only. |
| Credential | Provides a more secure way to specify the password for a login attempt using SQL Server Authentication. SQLServerCredential is comprised of a user id and a password that will be used for SQL Server Authentication. The SecureString object which holds the password should be marked Read-Only. |
| CurrentUser | Gets the currently authorized user specified by the UserName, or sets the current authorized user to a new value. When no value is defined, the data provider uses the user defined in the connection string. If the currently authorized user is not the same as the user defined in the original connection string, the data provider restores the user name, schema, path, and database. See Using Reauthentication for a description of OS authentication in a connection pool. |
| CurrentUserAffinityTimeout | Gets or sets the affinity timeout associated with the CurrentUser property. The value is expressed in milliseconds. The property helps the connection pool avoid unnecessary reauthentication. If CurrentUser is specified and the connection pool contains a physical connection that matches the CurrentUser, Open will occur more quickly. Increasing the CurrentUserAffinityTimeout can increase the chances that a connection with the same CurrentUser exists in the pool. However, when set too high, the connection pool might have to create new connections, which is more performance-expensive than reauthenticating an existing connection. The initial default is 0. The property’s value cannot be changed when the connection is open. Attempting to do so will result in an InvalidOperation exception. The property’s value is ignored if any of the following are true:
|
| DatabaseCharacterSetName | Set by the data provider on connection with the IANA name for the character set in the database to which the data provider has connected. Read-only. |
| DatabaseName | Returns the value specified for the Database Name connection string option. Read-only. |
| FetchBufferSize | Returns the value specified for the Fetch Buffer Size connection string option. Read-only. |
| Host | Gets the name of the host to which the data provider is connected. Read-only. The data provider predicts which host will be used for the connection, based on information in the connection string. If a change occurs during connection, for example, an Alternate Server is used, the Host property reports the actual host to which the data provider is connected. |
| PacketSize | Returns the value specified for the Packet Size connection string option. Read-only. |
| Port | Gets the name of the port to which the data provider is connected. Read-only. The data provider predicts which port will be used for the connection, based on information in the connection string. If a change occurs during connection, for example, an Alternate Server is used, the Port property reports the actual port to which the data provider is connected. |
| SelectMethod | Returns the value specified for the Select Method connection string option. Read-only. |
| Server | Returns the SQL Server server instance value specified in the connection string. Read-only. |
| StatisticsEnabled | Enables statistics gathering. When set to True, enables statistics gathering for the current connection. |
| Textsize | Returns the value specified for the Text Size connection string option. Read-only. |
| WorkstationID | Returns the value specified for the Workstation ID connection string option. Read-only. |
The following table lists the provider-specific public methods of the SQLServerConnection class. For a description of other methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
Public Methods Supported by the SQLServerConnection Class
| Method | Description |
| BeginTransaction() | Begins a transaction at the SQL Server database. When using the overloaded BeginTransaction(IsolationLevel) method, the SQL Server data provider supports the following .NET Framework isolation levels: Read Committed, Read Uncommitted, Repeatable Read, Serializable, and for Microsoft SQL Server 2005 and higher, Snapshot. Refer to the DataDirect Connect Series for ADO.NET Reference for more information about isolation. The initial default is Read Committed. |
| CurrentDatabase | Changes the current database for an open Connection class. The value specified must be the name of an existing database for the server the data provider is connected to. The database can be changed while reauthenticating users (see the Reauthentication Enabled connection string option in Connection String Options). |
| ResetStatistics | Resets all values to zero in the current statistics gathering session on the connection. When the connection is closed and returned to the connection pool, statistics gathering is switched off and the counts are reset. When the connection is closed and then reopened without calling the ResetStatistics method, statistics gathering continues without resetting the statistics counts. |
| RetrieveStatistics | Returns a name-value pair collection of statistics when the method is called. If the StatisticsEnabled property is set to False, the values retrieved are the initial values for the entry. Note: The SQL Server data provider does not report connection statistics. |
| SetOEMLicenseInfo | The SetOEMLicenseInfo method is for Progress DataDirect OEM customers only. Refer to the DataDirect Connect Series for ADO.NET Distribution Guide. |
| StatisticsEnabled | Enables statistics gathering for the current connection. When set to True, statistics gathering is enabled for the current connection. Note: Statistics counts are reset when the connection is closed and returned to the connection pool. |
SQLServerConnectionStringBuilder Class:
The SQLServerConnectionStringBuilder class has no provider-specific methods. For information about the methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
SQLServerConnectionStringBuilder property names are the same as the connection string option names of the SybaseConnection class. However, the connection string option name has spaces between the words. For example, the connection string option name Alternate Servers is equivalent to the property name AlternateServers.
See SQL Server Data Provider Connection String Options for the connection option descriptions, which are listed alphabetically by the connection string option name. The ConnectionStringBuilder property name is listed immediately underneath the GUI name.
SQLServerCredential Class
SQLServerCredential provides a more secure way to specify the password for a login attempt using SQL Server Authentication. SQLServerCredential is comprised of a user id and a password that will be used for SQL Server Authentication.
The password in a SQLServerCredential object is of type SecureString, unlike Connection String where password remains unsecure till the point where provider reads it and converts it to SecureString. The password is converted to string/ byte array in a secured way so that the conversion logic does not write the password in the memory. Any string where password is stored is cleaned after use.
Note: SQLServerCredential should not be used when the Authentication Method does not need user id and password. So, if you are using NTLM or Kerberos, you should not use SQLServerCredential.
Note: The Connection String should not have the User id and password when the Credential object is being used.
The following code snippet shows how the SQLServerCredential class can be used:
SQLServerConnection con = null;
SQLServerCredential lobjCredential = null;
string userId = "ABCD";
SecureString password = ConvertToSecureString("XYXYX");
private static SecureString ConvertToSecureString(string value)
{
var securePassword = new SecureString();
foreach (char c in value.ToCharArray())
securePassword.AppendChar(c);
securePassword.MakeReadOnly();
return securePassword;
}
try
{
lobjCredential = new SQLServerCredential(userId, password);
con = new SQLServerConnection("Host=nc-xxx;Port=xxxx;Database Name=xxxx", lobjCredential);
con.Open();
Console.WriteLine("Connection Successfully Opened...");
con.Close();
}
catch (Exception e)
{
Console.Write(e.Message)
}
finally
{
if (null != con)
{
con.Close();
con = null;
}
if (null != lobjCredential)
lobjCredential = null;
}
Note: The method followed to convert a string into a SecureString in this example is one of many possible methods you can use.
The following table lists the provider-specific implementation of the public properties of the SQLServerConnection class.
Public Properties of the SQLServerCredential Class
| Property | Description |
| User ID | Returns the user ID component of the SQLServerCredential object. Uses String data type. Invalid Values - NULL or empty. |
| Password | Returns the password component of the SQLServerCredential object. Uses SecureString data type. Invalid Values - NULL |
Note: If you are using Credential objects while opening the connection and want to use the same pooled connection, you need to use the same Credential object (Reference equal). Only then the same connection will be fetched from the available connection pool.
If you create a new Credential object for each connection, the driver will treat them as separate connection and put them into different connection pools. (Even if you use the same user id and password)
SQLServerDataAdapter Class
The following table lists the provider-specific implementation of the public properties of the SQLServerDataAdapter class. For information about other public properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
Public Properties of the SQLServerDataAdapter Class
| Property | Description |
| UpdateBatchSize | Gets or sets a value that specifies the number of commands that can be executed in a batch. If your application uses disconnected DataSets and updates those DataSets, you can positively influence performance by setting this property to a value greater than 1. By default, the data provider attempts to use the largest batch size possible. However, this may not equate to optimal performance for your application. The value you set depends on the number of rows you are typically updating in the DataSet. For example, if you are updating less than 50 rows, a suggested setting for this property is 25. When set to 0, the SQLServerDataAdapter uses the largest batch size the data source can support. The UpdatedRowSource property for the UpdateCommand, DeleteCommand, and InsertCommand must be set to None or OutputParameters. When set to 1, batch updating is disabled. When set to a value greater than 1, the specified number of commands are executed in a batch. The UpdatedRowSource property for the UpdateCommand, DeleteCommand, and InsertCommand must be set to None or OutputParameters. |
SQLServerDataReader Class
The SQLServerDataReader class has no provider-specific public properties or methods. For a description of the properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
SQLServerError Class
The following table lists the provider-specific public properties of the SQLServerError class. For information about other properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
Public Properties of the SQLServerError Class
| Property | Description |
| Procedure | Returns the name of the stored procedure that generated the error. The value is null if the statement did not include a stored procedure or batch. |
| SQLState | Returns the string representation of the SQL State when an exception is thrown by the SQL Server data provider. This property is read-only. |
SQLServerErrorCollection Class
The following table lists the provider-specific public properties of the SQLServerErrorCollection class. For information about other properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
Public Properties of the SQLServerErrorCollection Class
| Property | Description |
| Count | Returns the number of SQLServerError objects in the collection. |
| IsSynchronized | Gets a value indicating whether the SQLServerErrorCollection is synchronized (thread-safe). |
| Item | Gets the SQLServerError at the specified position. |
| SyncRoot | Gets the object used to synchronize access to the SQLServerErrorCollection. |
SQLServerException Class
Provider-specific exceptions are derived directly from the System.Data interface. Only the public properties and methods, for example, the Message property, are directly available on the System.Exception object in a generic sense. The SQLState and Number properties are only accessible through provider-specific code or by using reflection.
The following table lists the provider-specific public properties of the SQLServerException class. The properties apply to the last error collected if multiple errors occurred. For information about other properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
Public Properties of the SQLServerException Class
| Property | Description |
| Number | Returns the numeric value associated with a specific error. |
| SQLState | Returns the string representation of the SQLState when an exception is thrown by the SQL Server data provider. This property is read-only. |
SQLServerFactory Class
Provider Factory classes allow users to program to generic objects. Once instantiated from DbProviderFactory, the factory generates the proper type of concrete class.
The following table lists the static methods used to accommodate choosing the SQL Server data provider and instantiating its DbProviderFactory.
Methods of the SQLServerFactory Class
| Method | Description |
| CreateCommand | Returns a strongly typed DbCommand instance. |
| CreateCommandBuilder | Returns a strongly typed DbCommandBuilder instance. |
| CreateConnection | Returns a strongly typed DbConnection instance. |
| CreateConnectionStringBuilder | Returns a strongly typed DbConnectionString instance. |
| CreateDataAdapter | Returns a strongly typed DbDataAdapter instance. |
| CreateDataSourceEnumerator | Returns a strongly typed SQLServerDataSourceEnumerator instance. |
| CreateParameter | Returns a strongly typed DbParameter instance. |
| CreatePermission | Returns a new CodeAccessPermission. |
SQLServerInfoMessageEventArgs Class
The SQLServerInfoMessageEventArgs object is passed as an input to the SQLServerInfoMessageEventHandler and contains information relevant to a warning generated by the SQL Server server.
The SQLServerInfoMessageEventArgs object has no provider-specific properties or methods. For information about the properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
SQLServerParameter Class
The following table lists the provider-specific public properties of the SQLServerParameter class. The table includes the generic public properties of the Parameter class when provider-specific information supplements the standard descriptions. For information about other properties and methods supported, refer to the data provider’s online help and the Microsoft .NET Framework SDK documentation.
Note: When executing a stored procedure, the data provider by default assumes that the parameters supplied are in the same order as they were specified in the Create Procedure statement. The names of parameters supplied in the SQLServerParameter object are ignored.
Public Properties of the SQLServerParameter Class
| Property | Description |
| ArrayBindStatus | Determines whether any values in an array of SQLServerParameterStatus entries should be bound as null. The SQLServerParameterStatus enumeration contains the entry NullValue. When this property is not set, then no values are null. The length of the array should match the amount specified by the SQLServerCommand class's ArrayBindCount property (see "SQLServerCommand Class"). The initial default is null. |
| Precision | Gets or sets the maximum number of digits used to represent the Value property. Note: When using numeric output parameters in a stored procedure, you must supply the correct precision. |
| Scale | Gets or sets the number of decimal places to which Value is resolved. Note: When using numeric output parameters in a stored procedure, you must supply the correct scale. |
| SQLServerDbType | Gets or sets the SQL Server type of the parameter. |
| Value | Gets or sets the value of the parameter. This property is specified as an array of values when array binding is enabled (see the ArrayBindCount property of the "SQLServerCommand Class"). Each array's length must match the value of the ArrayBindCount property. When specifying the array's values for binary type columns, the data will actually be specified as byte[]. This is an array of arrays of bytes. The data provider anticipates a jagged array as such when using parameter array binding with parameters. To enable the use of streams as input to long data parameters, you set the Value property to a specific instance of the stream. See Using Streams as Input to Long Data Parameters for more information. |
SQLServerParameterCollection
The following table lists the provider-specific public properties of the SQLServerParameterCollection class. For information about other properties and methods supported, refer to the data provider’s online help.
Public Properties of the SQLServerParameterCollection Class
| Property | Description |
| IsFixedSize | Gets a value that indicates whether the ParameterCollection has a fixed size. |
| IsReadOnly | Gets a value that indicates whether the ParameterCollection is read-only. |
| IsSynchronized | Gets a value that indicates whether the ParameterCollection is thread-safe. |
| SyncRoot | Gets the object used to synchronize access to the ParameterCollection. |
SQLServerTrace Class
The SQLServerTrace class is created by the application to debug problems during development. Setting the properties in the SQLServerTrace class overrides the settings of the environment variables (see Connection String Options). For your final application, be sure to remove references to the SQLServerTrace class.
The following code fragment creates a SQLServerTrace class with a trace file named MyTrace.txt. All subsequent calls to the data provider will be traced to that file.
SQLServerObject.TraceFile="C:\\MyTrace.txt";
SQLServerObject.RecreateTrace = 1;
SQLServerObject.EnableTrace = 1;
The following table lists the public properties for the SQLServerTrace class.
Public Properties of the SQLServerTrace Class
| Property | Description |
| EnableTrace1 | When set to 1 or higher, enables tracing. When set to 0 (the initial default), tracing is disabled. |
| RecreateTrace | When set to 1, the trace file is re-created each time the application restarts. When set to 0 (the initial default), the trace file is appended. |
| TraceFile | Specifies the path and name of the trace file. The initial default is an empty string. If the file does not exist, the data provider creates it. |
1 Setting EnableTrace starts the tracing process. Therefore, you must define the property values for the trace file before setting EnableTrace. Once the trace processing starts, the values of TraceFile and RecreateTrace cannot be changed
The following table lists the public methods for the SQLServerTrace class.
Public Methods of the SQLServerTrace Class
| Method | Description |
| DumpFootprints | Displays the footprint of all source files in a data provider. |
SQLServerTransaction Class
The SQLServerTransaction class has no provider-specific public properties or methods. For a description of the properties and methods supported, refer to the online help and the Microsoft .NET Framework SDK documentation.