UltraLite databases are created with a default user ID of DBA and default password of sql; you must first connect as this initial user. New users must be added from an existing connection.
A user ID cannot be changed; instead, you add the new user ID and then delete the existing user ID. A maximum of four user IDs are permitted for each UltraLite database.
On Palm OS, if you want to authenticate users whenever they return to an application from some other application, you must include the prompt for user and password information in your PilotMain routine.
A complete sample can be found in the samples-dir\UltraLite\esqlauth directory. The code below is taken from samples-dir\UltraLite\esqlauth\sample.sqc.
//embedded SQL app() { ... /* Declare fields */ EXEC SQL BEGIN DECLARE SECTION; char uid[31]; char pwd[31]; EXEC SQL END DECLARE SECTION; db_init( &sqlca ); ... EXEC SQL CONNECT "DBA" IDENTIFIED BY "sql"; if( SQLCODE == SQLE_NOERROR ) { printf("Enter new user ID and password\n" ); scanf( "%s %s", uid, pwd ); ULGrantConnectTo( &sqlca, UL_TEXT( uid ), UL_TEXT( pwd ) ); if( SQLCODE == SQLE_NOERROR ) { // new user added: remove DBA ULRevokeConnectFrom( &sqlca, UL_TEXT("DBA") ); } EXEC SQL DISCONNECT; } // Prompt for password printf("Enter user ID and password\n" ); scanf( "%s %s", uid, pwd ); EXEC SQL CONNECT :uid IDENTIFIED BY :pwd; |
The code carries out the following tasks:
See:
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |