If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > SQL search function

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-15-09, 09:52
onurkaya onurkaya is offline
Registered User
 
Join Date: Feb 2006
Location: Turkiye
Posts: 15
SQL search function

Hi friends,

I'm trying create a search function but, I can't it. The criterias on result:


Code:
<table width="100%" border="0" cellspacing="2" cellpadding="3">
      <tr>
       <td>Date</td>
        <td>
        <select name="Tarih" style="width:125px;">
        	<option value="" > -- All -- </option>
            <option value="Bugun" > Today </option>

            <option value="Son3Gun" > Last 3 Day </option>
            <option value="Haftalik" > Last week </option>
            <option value="Aylik" selected="selected"> Last Month </option>
      </select>
        </td>
        <td>Contact type</td>

         <td> <select name="GorusmeTipi" style="width:125px;">
           <option value="" >-- All -- </option>
           <option value="1" >Face to face</option>
           <option value="0" >Phone</option>

           <option value="2" selected="selected">Not yet</option>
         </select></td>
        <td>Register Group</td>
        <td>
        <select name="KayitGrubu" style="width:125px;">
        <option value="" >-- All -- </option>

<option value="1">SBS - 6. Sınıflar</option><option value="2">SBS - 7. Sınıflar</option><option value="5">ÖSS - Hafta içi</option>
         </select></td>
      </tr>
      <tr>
        <td>Price</td>
        <td> <select name="Fiyat" style="width:125px;">
        	<option value="" > -- All -- </option>

            <option value="0" > 0 - 1000 TL </option>
            <option value="1" > 1000 - 2000 TL </option>
            <option value="2" > 2000 - 3000 TL </option>
            <option value="3" selected="selected"> 3000 - 4000 TL </option>
            <option value="4" > 4000 - 5000 TL </option>

            <option value="5" > 5000 TL + </option>
      </select></td>
        <td>Register state</td>
         <td><select name="Durum" style="width:125px;">
        	<option value="" > -- All -- </option>
            <option value="0" > Kayıt edilmedi </option>

            <option value="1" selected="selected"> Kesin kayıt </option>
            <option value="2" > Kayıt beklemede </option>
            <option value="3" > Belirsiz </option>
      </select></td>
        <td>Kayıt Olasılığı</td>

        <td><select name="Olasilik" style="width:125px;">
        	<option value="" > -- Tümü -- </option>
            <option value="0" > 0 </option>
            <option value="1" > 1 </option>
            <option value="2" > 2 </option>

            <option value="3" > 3 </option>
            <option value="4" > 4 </option>
            <option value="5" > 5 </option>
      </select></td>
      </tr>
      <tr>

        <td colspan="6" align="right"><input type="image" src="/images/sirala.jpg" style="width:100px; height:25px;" /></td>
        </tr>

    </table>

These codes were writen by me.

Code:
Dim Tarih : Tarih = Request.Form("Tarih")
Dim GorusmeTipi : GorusmeTipi = Request.Form("GorusmeTipi")
Dim KayitGrubu : KayitGrubu = Request.Form("KayitGrubu")
Dim Fiyat : Fiyat = Request.Form("Fiyat")
Dim Durum : Durum = Request.Form("Durum")
Dim Olasilik : Olasilik = Request.Form("Olasilik")
Dim RaporSQLS, TarihSQL, GorusmeTipiSQL, KayitGrubuSQL, FiyatSQL, DurumSQL, OlasilikSQL

If Tarih = "" Then
	TarihSQL = ""
ElseIf Tarih = "Bugun" Then
	TarihSQL = "[Tarih] = '" & Date() & "' AND "
ElseIf Tarih = "Son3Gun" Then
	TarihSQL = " ([Tarih] BETWEEN '" & DateAdd("d",-3,date()) & "' AND '" & Date() &"') AND "
ElseIf Tarih = "Haftalik" Then
	TarihSQL = " ([Tarih] BETWEEN '" & DateAdd("d",-7,date()) & "' AND '" & Date() &"') AND "
ElseIf Tarih = "Aylik" Then
	TarihSQL = " ([Tarih] BETWEEN '" & DateAdd("d",-30,date()) & "' AND '" & Date() &"') AND "
End If

If GorusmeTipi = "" Then
	GorusmeTipiSQL = ""
Else
	GorusmeTipiSQL = " [GorusmeTuru] = " & GorusmeTipi & " AND "
End If

If KayitGrubu = "" Then
	KayitGrubuSQL = ""
Else
	KayitGrubuSQL = " [GrupID] = " & KayitGrubu & " AND "
End If

If Fiyat = "" Then
	FiyatSQL = ""
ElseIf Fiyat = "0" Then
	FiyatSQL = " ([Fiyat] BETWEEN '0' AND '1000') AND "
ElseIf Fiyat = "1" Then
	FiyatSQL = " ([Fiyat] BETWEEN '1001' AND '2000') AND "
ElseIf Fiyat = "2" Then
	FiyatSQL = " ([Fiyat] BETWEEN '2001' AND '3000') AND "
ElseIf Fiyat = "3" Then
	FiyatSQL = " ([Fiyat] BETWEEN '3001' AND '4000') AND "
ElseIf Fiyat = "4" Then
	FiyatSQL = " ([Fiyat] BETWEEN '4001' AND '5000') AND "
ElseIf Fiyat = "5" Then
	FiyatSQL = " [Fiyat] >= '5001' AND "
End If

If Durum = "" Then
	DurumSQL = ""
Else
	DurumSQL = " [Durum] = " & Durum & " AND "
End If

If Olasilik = "" Then
	OlasilikSQL = ""
Else
	OlasilikSQL = " [Olasilik] = " & Olasilik & " "
End If

Dim RaporSay : RaporSay = 1
Do while not RaporRS.eof
	
	If GorevForm = "1" Then
		If Tarih = "" or GorusmeTipi = "" or KayitGrubu = "" or Fiyat = "" or Durum = "" or Olasilik = "" Then
			Session("Tarih") = Tarih
			Session("GorusmeTipi") = GorusmeTipi
			Session("KayitGrubu") = KayitGrubu
			Session("Fiyat") = Fiyat
			Session("Durum") = Durum
			Session("Olasilik") = Olasilik
			Response.Redirect("/Raporlar.asp?Gorev=1")
		Else
			RaporSQLS = "SELECT [OgrenciID], [Tarih], [isim], [GorusmeTuru], [GrupID], [Fiyat], [Fiyat2], [Durum], [Olasilik] FROM [Ogrenciler] WHERE " & TarihSQL & "" & GorusmeTipiSQL & "" & KayitGrubuSQL & "" & FiyatSQL & "" & DurumSQL & "" & OlasilikSQL & " ORDER BY [isim] ASC"
		End If
	Else
		RaporSQLS = "SELECT [OgrenciID], [Tarih], [isim], [GorusmeTuru], [GrupID], [Fiyat], [Fiyat2], [Durum], [Olasilik] FROM [Ogrenciler] WHERE [GrupID] = " & RaporRS("GrupID") & " ORDER BY [isim] ASC"
	End If
	
	Dim Rapor2RS, Rapor2SQL
	Set Rapor2RS = Server.CreateObject("ADODB.Recordset") 
	Rapor2SQL = RaporSQLS
	Rapor2RS.Open Rapor2SQL, DizaynWebBaglanti, 1, 3
şeklinde devam ediyor. yardımlarınızı bekliyorum. şimdiden teşekkürler.
__________________
HAVE RESPECT FOR AS LONG AS.
Reply With Quote
  #2 (permalink)  
Old 10-15-09, 13:14
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,002
What line is your error?
What is the value of Rapor2SQL before this error occurs?
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On