It should be like this:
strSelect = "SELECT ISBN, V_Title, V_Type, V_Actor, V_Time
FROM Video_Catalog where 1 = 1";
if Type is not null or Type != "ALL"
strSelect = strSelect + "And VideoType = '" + Type + "'"
end if
if Title is not null
strSelect = strSelect + "And VideoTitle = '" + Title + "'"
end if
if Actor is not null
strSelect = strSelect + "And VideoActor = '" + Actor + "'"
end if
above is the pseudo code, you modify it according to the relevant syntax.
<% rs = statement.executeQuery( strSelect ); %>
Regds
Murugan K Patham
480 - 990 4200 Ext 2712
>>> [EMAIL PROTECTED] 03/01 8:36 PM >>>
Hi all,
I did the code for searching video.
My purpose is the user may enter
Type, Title or Actor, or either any
two of them, or all of them.
The code can work individually, but
after put them together, it only works on
last query which to enter all of them
three. Could anyone give any idea?
Thanks in advance!!
Code:
<%
if( VideoType == "ALL" )
{
if( VideoTitle == "" )
{
if( VideoActor == "" ) {
strSQL = "SELECT ISBN, V_Title, V_Type,
V_Actor, V_Time FROM
Video_Catalog";
}
else {
strSQL = strSELECT + "V_Actor = '" +
VideoActor + "'";
}
}
else
{
if( VideoActor=="" ) {
strSQL = strSELECT + "V_Title = '" +
VideoTitle + "'";
}
else {
strSQL = strSELECT + "V_Title = '" +
VideoTitle + "' AND V_Actor = '" +
VideoActor + "'";
}
}
}
else
{
if( VideoTitle=="")
{
if( VideoActor==""){
strSQL = strSELECT + "V_Type = '" + VideoType
+ "'";
}
else{
strSQL = strSELECT + "V_Type = '" + VideoType
+ "' AND V_Actor = '" + VideoActor
+ "'";
}
}
else
{
if( VideoActor==""){
strSQL = strSELECT + "V_Type = '" + VideoType
+ "' AND V_Title = '" + VideoTitle
+ "'";
}
else {
strSQL = strSELECT + "V_Type = '" + VideoType
+ "' AND V_Title = '" + VideoTitle +
"' AND V_Actor = '" + VideoActor + "'";
}
}
}
%>
<% rs = statement.executeQuery( strSQL ); %>
Jun Wang
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets