SQLBind (function)




Specifies which fields are returned when results are requested using the SQLRetrieve or SQLRetrieveToFile function.


The following table describes the parameters to the SQLBind function:






Long parameter specifying a valid connection.



Any array of variants. Each call to SQLBind adds a new column number (an Integer) in the appropriate slot in the array. Thus, as you bind additional columns, the array parameter grows, accumulating a sorted list (in ascending order) of bound columns.

If array is fixed, then it must be a one-dimensional variant array with sufficient space to hold all the bound column numbers. A runtime error is generated if array is too small.

If array is dynamic, then it will be resized to exactly hold all the bound column numbers.



Optional Long parameter that specifies the column to which to bind data. If this parameter is omitted, all bindings for the connection are dropped.

The first actual column in the table is column 1.

(If supported by the driver) row numbers can be returned by binding column 0.


This function returns the number of bound columns on the connection. If no columns are bound, then 0 is returned. If there are no pending queries, then calling SQLBind will cause an error (queries are initiated using the SQLExecQuery function).

If supported by the driver, row numbers can be returned by binding column 0.

The Basic Control Engine generates a runtime error that can be trapped if SQLBind fails. Additional error information can then be retrieved using the SQLError function.


This example binds columns to data.

Sub Main()
  Dim columns() As Variant
  id& = SQLOpen("dsn=SAMPLE",,3)
  t& = SQLExecQuery(id&,"Select * From c:\sample.dbf")
  i% = SQLBind(id&,columns,3)
  i% = SQLBind(id&,columns,1)
  i% = SQLBind(id&,columns,2)
  i% = SQLBind(id&,columns,6)
  For x = 0 To (i% - 1)
    MsgBox columns(x)
  Next x
  id& = SQLClose(id&)
End Sub

See Also

SQLRetrieve (function); SQLRetrieveToFile (function).




More information