Struct odbc_safe::DataSource [] [src]

pub struct DataSource<'env, S: HDbcWrapper<'env> = Unconnected<'env>> { /* fields omitted */ }

A DataSource is used to query and manipulate a data source.

  • The state of the connection
  • The current connection-level diagnostics
  • The handles of statements and descriptors currently allocated on the connection
  • The current settings of each connection attribute

States

A DataSource is in one of two states Connected or Unconnected. These are modeled in the type at compile time. Every new DataSource starts out as Unconnected. To execute a query it needs to be Connected. You can achieve this by calling e.g. connect and capture the result in a new binding which will be of type DataSource::<'env, Connected<'env>>.

See Connection Handles in the ODBC Reference

Methods

impl<'env, Any> DataSource<'env, Any> where
    Any: HDbcWrapper<'env>, 
[src]

Consumes the DataSource, returning the wrapped raw SQLHDBC

Leaks the Connection Handle. This is usually done in order to pass ownership from Rust to another language. After calling this method, the caller is responsible for invoking SQLFreeHandle.

Provides access to the raw ODBC Connection Handle

May only be invoked with a valid Statement Handle which has been allocated using SQLAllocHandle. Special care must be taken that the Connection Handle passed is in a State which matches the type.

impl<'env> DataSource<'env, Unconnected<'env>>
[src]

Allocates a new DataSource. A DataSource may not outlive its parent Environment.

See Allocating a Connection Handle ODBC

Establishes connections to a driver and a data source. The connection handle references storage of all information about the connection to the data source, including status, transaction state, and error information.

State transition

On success this method changes the Connection handles state from Allocated to Connected . Since this state change is expressed in the type system, the method consumes self. And returns a new instance in the result type.

Arguments

  • data_source_name - Data source name. The data might be located on the same computer as the program, or on another computer somewhere on a network.
  • user - User identifier.
  • pwd - Authenticatien string (typically the password).

Connects to a data source using a connection string.

For the syntax regarding the connections string see SQLDriverConnect. This method is equivalent of calling odbc_sys::SQLDriverConnect with the SQL_DRIVER_NOPROMPT parameter.

See Choosing a Data Source or Driver

Trait Implementations

impl<'env, S: Debug + HDbcWrapper<'env>> Debug for DataSource<'env, S> where
    S::Handle: Debug
[src]

Formats the value using the given formatter.

impl<'env, S> Diagnostics for DataSource<'env, S> where
    S: HDbcWrapper<'env>, 
[src]

Returns the current values of multiple fields of a diagnostic record that contains error, warning, and status information. Read more