[][src]Struct odbc_api::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 fn exec_direct_utf16(
    &mut self,
    query: &U16Str,
    params: impl ParameterCollection
) -> Result<Option<CursorImpl<'_, Statement<'_>>>, Error>
[src]

Executes a statement. This is the fastest way to submit an SQL statement for one-time execution.

Parameters

  • query: The text representation of the SQL statement. E.g. "SELECT * FROM my_table;". A question mark (?) may be used to indicate positional parameters in the statement text.
  • params: Used to bind the placeholders in the statement text to argument values You can use () to represent no parameters.

Return

Returns Some if a cursor is created. If None is returned no cursor has been created ( e.g. the query came back empty). Note that an empty query may also create a cursor with zero rows.

pub fn execute(
    &mut self,
    query: &str,
    params: impl ParameterCollection
) -> Result<Option<CursorImpl<'_, Statement<'_>>>, Error>
[src]

Executes a prepareable statement. This is the fastest way to submit an SQL statement for one-time execution.

Parameters

  • query: The text representation of the SQL statement. E.g. "SELECT * FROM my_table;".
  • params: ? may be used as a placeholder in the statement text. You can use () to represent no parameters.

Return

Returns Some if a cursor is created. If None is returned no cursor has been created ( e.g. the query came back empty). Note that an empty query may also create a cursor with zero rows.

Example

use odbc_api::Environment;

// I herby solemnly swear that this is the only ODBC environment in the entire process, thus
// making this call safe.
let env = unsafe {
    Environment::new()?
};

let mut conn = env.connect("YourDatabase", "SA", "<YourStrong@Passw0rd>")?;
if let Some(cursor) = conn.execute("SELECT year, name FROM Birthdays;", ())? {
    // Use cursor to process query results.  
}

pub fn prepare_utf16(&self, query: &U16Str) -> Result<Prepared<'_>, Error>[src]

Prepares an SQL statement. This is recommended for repeated execution of similar queries.

Parameters

  • query: The text representation of the SQL statement. E.g. "SELECT * FROM my_table;". ? may be used as a placeholder in the statement text, to be replaced with parameters during execution.

pub fn prepare(&self, query: &str) -> Result<Prepared<'_>, Error>[src]

Prepares an SQL statement. This is recommended for repeated execution of similar queries.

Parameters

  • query: The text representation of the SQL statement. E.g. "SELECT * FROM my_table;". ? may be used as a placeholder in the statement text, to be replaced with parameters during execution.

Trait Implementations

impl<'conn> Drop for Connection<'conn>[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.