IDC 2 | Applications | IDC 1 | FrontPage 97 |
Example: Show only Selected database records.
Note: These examples are written for use with FrontPage 97.
These examples work using MS Access. The Database is named "IDCTest.mdb", a table named "TestTable" is used which has the fields "IDnumber", "Name" and "Misc". The DSN file name is IDCsample.
In preparation for this example, you must read the "IDC1 Example: Show ALL database records".
Create the IDC file
From the Top Menu of FrontPage Explorer, select | File | New | ....highlight the "Database Connector Wizard" and click the OK button.
The "Internet Database Connector Wizard window will open.
Type IDCsample in the "ODBC data source:" text box
Type IDCshowAllResults.htx in the "Query results template:" text box ( or use the browse button to select this file).
Press the Next button to continue
Type "select IDnumber, Name, Misc from TestTable where TestTable.Name='%NameTxt%' in the text box. The text NameTxt will be used to name the text box on the web page.
The SQL window
...and press the Finish button.
To be able to retrieve embedded text words you can substitute the entry
...where TestTable.Name Like '%%%NameTxt%%%'
The IDC is now complete. This particular IDC will retrieve only selected records determined by a value typed in on the text box shown in the web browser's page.
Modify the HTM page which will start the query and show the results
Load the Web that was used in Example 1.
Use the page that was created in Example 1 (the index.htm page ).
Open the Index.htm page in the FrontPage Editor.
Scroll to a blank area on towards the bottom of the page.
Select Insert from the menu at the top of the page.
The Insert pop-down menu will open. Slide the mouse down and select | Form Field | "One Line Text Box"
A text box will be placed on the web page.
Right click on the text box and select "Form Field Properties" form the pop-up window.
In the "Name:" text box enter the word "NameTxt". This entry must be exactly the same as the one entered in the SQL section of the IDC shown above.
and click the OK button to close the window.
As in the example above, select | Insert | Form Field | from the top menu but this time select the "Push Button" selection.
The Submit button will appear.
At this point the index.htm page will look as follows.
Now with the mouse, Right-Click on the empty area to the right of the Submit button. Select the Form Properties from the pop-up window.
The Form Properties window will appear.
Click on the down arrow of the form handler text box
Select the entry "Internet Database Connector" from the drop-down list.
Now click on the Settings button on the top right corner of the window.
The "Settings for IDC" window will open.
Click on the Browse button. The Browse window will open.
Double click on the folder "Run_Files" to open that folder.
Select the entry "IDCselectSome.idc" ( this is the IDC that was created earlier).
and click the OK button.
The entry will be placed in the "Settings for Database Connector" window.
Click the OK button to finish. This will take you to the "Form Properties" window. Click Ok again to close that window.
At this point you are done. Make sure you save the FrontPage Editor page. Also make sure you have some data in the database table.
Open a browser and then go to the page where the link was placed. Most likely the Index.htm (if you followed the above instructions).
When the page opens you should see the Text Box and the Submit button.. Place a text value in the text box (i.e. Mike). When you click on the submit button, the IDC should execute and the results page should load with records from the database which have an exact match to the word you typed into the text box in the web page.
Don't hesitate to give feedback, good or bad regarding this page. Either email the webmaster (bottom of page) or leave a message in the Guest Book which is located on the home page (see top right corner of this page).
The next tutorial coming up will deal with adding records to a database with IDC.
To insert records, follow all the instructions above
Using "Insert Into"
The IDC query will be similar to the following
Insert Into TestTable(Name,Number1) values ('%NameTxt%', %NumberIn%)
In this query, the web form will have two input box named "NameTxt" and "NumberIn" and the submit button. When the button is pressed, the text or number entered on the web form input boxes will be added to the database table "TestTable" in the fields "Name" and "Number1".
In this example both a text and a number field were used to show how they are treated.
The web form Text box field is enclosed in single quotes and percent signs.
The numeric field is enclosed only in percent signs.
|You are at the www.techadvice.com site which is not associated with the company or products shown on this page.|