JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Using the SqlConnection Class

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.

Table 22.4: Noteworthy public properties of SqlConnection objects.

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.

Table 22.5: Noteworthy public methods of SqlConnection objects.

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.

Table 22.6: Noteworthy public events of SqlConnection objects.

Event

Means

InfoMessage

Occurs if the provider sends a message (including warnings).

StateChange

Occurs when a connection's state changes.

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor