Visual J++ provides the DataSource control to access data in the Designer. This control allows you to connect to and query a database to retrieve a set of records.
Note To retrieve a recordset in code, you can also use the Connection, Command, and Recordset components. The Designer, however, only supports the DataSource component. For information about programming with the ADO components, see the ADO Tutorial (VJ++).
The following steps show how to use the DataSource control in the Designer. (You must have already added this control to the Toolbox.)
To retrieve data with the DataSource control
Note Because the DataSource control only retrieves data and does not display it, the control is not visible when you run your form.
DSN=dataSourceName;UID=userID;PWD=password;
If no user ID and password are associated with this data source, you can omit the UID and PWD tags. Note that you can also specify this string with OLEDB tags:
Data Source=dataSourceName;User ID=userID;Password=password;
Provider=Microsoft.Jet.OLEDB.3.51;Data Source=fileName;User ID=userID;Password=password;
In the previous string, fileName specifies the full path and name of the .mdb file. If no users have been created, you can omit the User ID and Password tags.
Now that you have retrieved a set of records, you must bind the data to display it on the form.