Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (Français) » SQL Anywhere Server - Programming » SQL Anywhere Data Access APIs » SQL Anywhere C API reference » sacapi.h


sqlany_connect function

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

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

  • str    A SQL Anywhere connection string.


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
 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 );