[][src]Struct odbc_api::handles::Connection

pub struct Connection<'c> { /* fields omitted */ }

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

Implementations

impl<'c> Connection<'c>[src]

pub unsafe fn new(handle: HDbc) -> Self[src]

Safety

Call this method only with a valid (successfully allocated) ODBC connection handle.

pub fn connect(
    &mut self,
    data_source_name: &U16Str,
    user: &U16Str,
    pwd: &U16Str
) -> Result<(), Error>
[src]

Establishes connections to a driver and a data source.

  • See [Connecting with SQLConnect][1]
  • See [SQLConnectFunction][2]

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 - Authentication string (typically the password). [1]: https://docs.microsoft.com/sql/odbc/reference/syntax/sqlconnect-function [2]: https://docs.microsoft.com/sql/odbc/reference/syntax/sqlconnect-function

pub fn connect_with_connection_string(
    &mut self,
    connection_string: &U16Str
) -> Result<(), Error>
[src]

An alternative to connect. It supports data sources that require more connection information than the three arguments in connect and data sources that are not defined in the system information.

pub fn disconnect(&mut self) -> Result<(), Error>[src]

Disconnect from an ODBC data source.

pub fn allocate_statement(&self) -> Result<Statement<'_>, Error>[src]

Allocate a new statement handle. The Statement must not outlive the Connection.

pub fn set_autocommit(&mut self, enabled: bool) -> Result<(), Error>[src]

Specify the transaction mode. By default, ODBC transactions are in auto-commit mode (unless SQLSetConnectAttr and SQLSetConnectOption are not supported, which is unlikely). Switching from manual-commit mode to auto-commit mode automatically commits any open transaction on the connection.

pub fn commit(&mut self) -> Result<(), Error>[src]

To commit a transaction in manual-commit mode.

pub fn rollback(&mut self) -> Result<(), Error>[src]

Roll back a transaction in manual-commit mode.

Trait Implementations

impl<'c> AsHandle for Connection<'c>[src]

impl<'c> Drop for Connection<'c>[src]

Auto Trait Implementations

impl<'c> RefUnwindSafe for Connection<'c>

impl<'c> !Send for Connection<'c>

impl<'c> !Sync for Connection<'c>

impl<'c> Unpin for Connection<'c>

impl<'c> UnwindSafe for Connection<'c>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.