sqlany_connect function

Creates a connection to a SQL Anywhere database server using the specified connection object and connection string.

Syntax
sacapi_bool sqlany_connect( a_sqlany_connection * conn, const char * str )
Parameters
  • conn   The connection object created by sqlany_new_connection.

  • str    A SQL Anywhere connection string.

Returns

1 if the connection is established successfully or 0 when the connection fails. Use sqlany_error to retrieve the error code and message.

See also
Example
 a_sqlany_connection * conn;
   conn = sqlany_new_connection();
   if( !sqlany_connect( conn, "uid=dba;pwd=sql" ) ) {
        char           reason[SACAPI_ERROR_SIZE];
        sacapi_i32     code;
        code = sqlany_error( conn, reason, sizeof(reason) );
        printf( "Connection failed. Code: %d Reason: %s\n", code, reason );
   } else {
        printf( "Connected successfully!\n" );
        sqlany_disconnect( conn );
   }
   sqlany_free_connection( conn );