SqlUse%

Sets the current database for a particular SQL Server connection.

Syntax

SqlUse% ( sqlconn%, sqlname$ )

where

sqlconn% ( )
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.
sqlname$
Is a string containing the database name.

Returns

SUCCEED (1) or FAIL (0).

Remarks

SqlUse% sets up the Transact-SQL USE statement and calls SqlExec% and SqlResults%. If the USE statement fails because the requested database has not yet completed a recovery process, SqlUse% continues to send USE statements at 1-second intervals until it succeeds or it encounters some other error.

Before SqlUse% sets the current database, it calls SqlFreeBuf to clear the command buffer. If you call SqlCmd% to place statements into the command buffer, execute these statements before calling SqlUse%.

See Also

SqlExec%, SqlResults%