![]() ![]() | ||
The SqlConnection class represents a connection to a SQL Server database. Here is the inheritance hierarchy of this class:
Object MarshalByRefObject Component SqlConnection
You can find the more notable public properties of SqlConnection objects in Table 22.4, their more notable methods in Table 22.5, and their more notable events in Table 22.6.
Property |
Means |
---|---|
ConnectionString |
Gets/sets the connection string to open a database. |
ConnectionTimeout |
Gets the amount of time to wait trying to make a connection. |
Database |
Gets the name of the database to open. |
DataSource |
Gets the name of the SQL Server to use. |
PacketSize |
Gets the size of communication packets to use (in bytes). |
ServerVersion |
Gets the version of the server. |
State |
Gets the connection's current state. |
WorkstationId |
Gets the database client ID. |
Method |
Means |
---|---|
BeginTransaction |
Starts a database transaction. |
ChangeDatabase |
Changes the current database. |
Close |
Closes the connection to the data provider. |
CreateCommand |
Creates an OleDbCommand object for this connection. |
Open |
Opens a database connection. |
Event |
Means |
---|---|
InfoMessage |
Occurs if the provider sends a message (including warnings). |
StateChange |
Occurs when a connection's state changes. |
![]() ![]() | ||