Accessing Citadel 4 Data from Visual Basic
- Note: Visual Basic software relies on Microsoft Access DLLs for performing ODBC queries. Because it uses the Access non-standard SQL syntax, be sure that Convert Special Characters is selected in the Citadel ODBC Setup dialog box.
1. Place a data control on an open form.
2. Set its Connect property to DSN=Citadel and double-click on its Record Source property to identify Traces as its source table.
3. If you want to select all of the data for all traces in the Citadel database, leave the Record Source property set to Traces. If you want to narrow your query, enter an SQL select statement in the Record Source property.
For example, to retrieve LocalTime, Pot1, and AB1.I:3 where LocalTime is greater than 11/20/95 18:00:00 and less than 18:30:00, and where Interval is one minute, enter the following query:
SELECT LocalTime, ["Pot1"], ["AB1@I:3"]
FROM Traces
WHERE LocalTime > #11/20/95 6:00:00 PM#
AND LocalTime < #11/20/95 6:30:00 PM#
AND Interval = '1:0'
Note: Remember to use the Microsoft Access SQL syntax in the select statement, convert special characters for Access compatibility (see Table), place double quotes around Lookout trace names to identify them as delimited identifiers, enclose identifiers in square brackets ([ ]), and place pound signs (#) around time stamps.
5. Set its Data Source property to the name of your data control—for example, Data1.
6. Click on the Data Field property to highlight it and then use the property sheet drop-down combo box to select the desired field name. All logged data members should be listed including LocalTime, Interval, and Pot1.
7. Repeat steps 4 through 6 for each data member you want to display on your form.
If you are using Visual Basic 4 or later, you might get a Visual Basic warning telling you "Object variable or with block variable not set."
The following steps should help if this problem arises:
1. Make sure that the Citadel ODBC is properly installed. Select Control Panel»32-bit ODBC and choose the Users DSN tab. You should see your Citadel data source listed. If you do not, you must create it. See the document on "Setting up Citadel as an ODBC Data Source" for more information.
2. Make sure you have placed a data control on your open form.
3. Set the Connect property of the data control to ODBC;DSN=Citadel (or any other name you defined in the Users DSN tab in step 1). You should now be able to see Traces in the Record Source property.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
