SqlCmd%

Adds Transact-SQL text to the command buffer.

Syntax

SqlCmd% ( sqlconn%, cmd$ )

where

sqlconn%
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.
cmd$
Is a character string to be copied into the command buffer.

Returns

SUCCEED (1) or FAIL (0).

Remarks

SqlCmd% adds text to the existing command buffer. The added text does not delete or overwrite the current contents until the contents of the buffer are sent to SQL Server.

After a call to SqlExec% or SqlSend%, the first call to SqlCmd% automatically clears the command buffer before the new text is entered. If you do not want the command buffer automatically cleared, set the sqlnoautofree option with SqlSetOpt%. When sqlnoautofree is set, the command buffer is cleared only by a call to SqlFreeBuf.

The size of the command buffer depends on the amount of available memory.

Note You can call SqlCmd% repeatedly. Sequential calls are concatenated, so be sure to add any necessary blanks at the end of one line or the beginning of the next.

Example

The following code fragment shows how to use SqlCmd% to build up a multiline SQL command:

Result% = SqlCmd%(Sqlconn%, "SELECT name FROM sysobjects")
Result% = SqlCmd%(Sqlconn%, " WHERE id = 5")
Result% = SqlCmd%(Sqlconn%, " AND type = 'S'")

See Also

SqlFreeBuf; DB-Library for Visual Basic Options