Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Creating a Conditional List
A- What are you going to do? Create an appropriate form design according to
the search condition
You will “list” “specific records” of a database. (it means you will use a condition!)
Exp:
Please write down the student lastname to be found:
İkinci
Lastname:
Find
B- Design your database if it is not exist
C- Add some records to your database (it must be some records to list them!)
D- Create a sample design to determine how the data to be displayed.
Name
Arzu
Surname
İkinci
City
1
E- Save the sample design web page with the extension of ASP!
1
Creating a Conditional List
F- Necessary ASP codes must be written to the sample design web page
1.
Create a Database Connection Object
Open the Database Connection Object
After the <BODY>
Close the Database Connection Object
Clear the Database Connection VariableBefore the </BODY>
2.
Create a record set Object: Set rs1 = server. CreateObject("ADODB.Recordset")
Create a query set:
Fill record set with executed query result:
sq1= "SELECT * FROM kayit WHERE"
set rs1 = conn341.execute(sq1)
2
Creating a Conditional List
In order to read all of the records you must built a LOOP!
- How many records will be listed? :(
- Which of the fields must be listed? :)
- In which presentation format? :)
- Which part of the HTML code must be repeated with ASP Codes? :)
do while not kayitseti.eof
response.write kayitseti("kayitAdi")
kayitseti.movenext
loop
3
Creating a Conditional List
Query Examples
in SQL sentence
Name = tuna
“SELECT * FROM student WHERE stuName = ‘tuna’ ”
Surname = ikinci
“SELECT * FROM student WHERE stuSurname = ‘ikinci’ ”
Student name
starts with A
“SELECT * FROM student WHERE stuName LIKE ‘A%’ ”
Student surname
includes “inci”
“SELECT * FROM student WHERE stuSurname LIKE ‘%inci%’ ”
Student birth year,
Later than 1980
“SELECT * FROM student WHERE stuByear > 1980 ”
4
Creating a Conditional List
•
You want the students from the student table “if a student name is tuna”;
SQ1 = “SELECT * FROM student WHERE stuName = ‘tuna’ ”
•
If you want to list the students according to the name which is written to
a text box or selected from a drop down?!!
“tuna” is coming from a text box or drop down =>
tuna = “ & request.form(“txtstuName”) & “
SQ1 = “SELECT * FROM student WHERE stuName = ‘ ’ ”
•
If you want the list to be sorted;
SQ1 = “SELECT * FROM student WHERE stuName = ‘ ’ ORDER BY stuSurname”
5
Creating a Conditional List :
•
Request.QueryString
You want the students from the student table “if a student name
is tuna”;
<A HREF = “findastu.asp?stu=a”>A</A>
SQ1 = “SELECT * FROM student WHERE stuSurname = ‘A%’ ”
•
If you want to list the students according to the surname which is
selected from a link!
“A” is coming from a link box or drop down =>
A = “ & request.querystring(“stu”) & “
SQ1 = “SELECT * FROM student WHERE stuSurname = ‘ ’ ”
6