Download presentation
Presentation is loading. Please wait.
1
Searching Your Database
Lesson 10 Searching Your Database
2
Dynamic Searches via a web page
Searching a database is quite common when using a database The Code Builders once again will be used to create the necessary code you’ll need to make this happen Create a new ASP.Net file and call it FindActress
3
Select Code Builder Click on Code
Left Click over Select Data Method and drag it over your workspace Click the down arrow to the right of Database: Select the Movies Database, click Ok
4
Construct A Select Query
Click on the following: MovieName Actress Director
5
Where Clause Builder Click on Actress
Locate Operator- Click the down arrow and select like Locate Filter- Click Ok
6
Here’s what you have
7
Test Query Click Next Click Test Query Type Jill St. John
Does the Query work?
8
Creating A Method Type FindByActress to create this method
Click Finish
9
Using FindByActress Method
Click on Design View Type Bond Actresses on the workspace Drag a TextBox from the Web Control Toolbox and place it to the right of Bond Actresses Drag a button and place it to the right of your TextBox Drag a DataGrid and place it on the workspace Click on Layout from the Menu Bar and click on Absolute Position and move the DataGrid to the middle of your workspace
10
Finished Design View
11
Tying It All Together Double click the button to create a Click event
This code will use the FindByActress method that was created so that when you click the button the user will type in the Bond Actress and the Movies Database will then locate that record and create the table on the web page
12
Type the code in white Sub Button1_Click(sender As Object, e As EventArgs) Dim sActress As String = TextBox1.Text DataGrid1.DataSource = FindByActress(sActress) DataGrid1.DataBind() End Sub
13
Read To Test? Click Save to save the file
Press F5 and load the browser software to view Type Jill St. John in the Textbox and click the button
14
Modifying The Web Page Your page looks kind of boring so let’s dress it up with some changes. Click on the DataGrid Go to AutoFormat which is below the Property on the right bottom Select Colorful5 Change the Font to Georgia and the size to 5
15
More changes Highlight Find Actresses and change the font size to 5 and Go to Format and change the Foreground color to Red Click the button and look at the Properties Change the Fore Color to red and the Back Color to yellow Change the Text to Go Press F5 to see your changes
16
Change the colors if you don’t like them
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.