Title:

Description:

Doesn't use a Data Access Object. Note the SQLPassThrough flag on the OpenRecordset command. This will produce the highest level of optimization possible. Also note that this example assumes that "myds" is a valid datasource as defined in the ODBC administrator, and that that "table" and "field1" refer to a valid table within the datasource and a valid field within the table.

Dim db As Database Dim ws As Workspace Dim rs As Recordset

rem set the first string to "" and the second to "ODBC;" to have the user select a datasource from the ODBC administrator during run-time. Set db = Workspaces(0).OpenDatabase("myds", False, False, "ODBC;Database=myds") SQL$ = "SELECT field1 FROM table WHERE field1 BETWEEN 'A' and 'B' ORDER BY field1" Set rs = db.OpenRecordset(SQL$, dbOpenDynaset, dbSQLPassThrough)

Do Until rs.EOF List1.AddItem rs("field1") rs.MoveNext Loop

Changes the window's title to indicate how many records were selected Form1.Caption = "Records Found: " + Str(rs.RecordCount) db.Close

Using a Data Access Object to connect to the datasource. Note that there is no code, just the data object and potentially other data-aware controls. Again, assume that "myds" is a valid datasource

1) Include a Data object with these properties Connect: ODBC;DSN=myds DatabaseName: can be blank if Connect references a valid ODBC datasource RecordSource: This can either be a table, or a valid SQL statement to produce a resultant table

2) Include data-aware controls (we'll use a textbox for this example) Datafield: select a valid field from the RecordSource Datasource: select the data object from step 1

This example uses RDO in VB5 to update an ODBC record. Because version 1.1 of our ODBC driver does not support cursors, it is not possible to update the data using the Recordset object; updates can only be done using SQL. Ensure that you've added the 'Microsoft Remote Data Object 2.0' to the project via the Project/References menu option.

This example uses ADO in VB6 to display all of the records in the BASIS Chile Company demo database that shipes with the 2.0x version of the BASIS ODBC Driver. Ensure that you've added the Microsoft ActiveX Data Objects to the project via the Project/References menu option. Note that you can also create a fully functioning example with ADO via Visual Basic's VB Application Wizard.