|
 |
asp_databases thread: searching for multiple items in one database
Message #1 by tim.puffer@t... on Fri, 30 Nov 2001 21:31:57
|
|
I am trying to look for several items in one database. I think i am on
the write track ??? could someone take a look at my code and let me know
if i am close?
this is the response.write that it generates.
SELECT * FROM newbookings WHERE LIKE '%40%' AND '%2001%' AND '%bic%'ORDER
by
Here is my code.
<%
dim varIn, varFind1, varfind2,varfind3, varfind4, varfind5,
cnbook, connstr, theMessage, sqltext, rsbook, varsort, total
varsort= Request.Form("sort")
varIn = Request.form("in")
varFind1 = Request.form("find1")
varFind2 = Request.form("find2")
varFind3 = Request.form("find3")
varFind4 = Request.form("find4")
varFind5 = Request.form("find5")
response.write varFind1
response.write varFind2
response.write varFind3
response.write varFind4
response.write varFind5
' response.write varIn
' reponse.write varsort
' reponse.write total
set cnbook = server.createobject ("adodb.connection")
connstr = "driver={microsoft access driver (*.mdb)};" & _
"dbq=" & server.MapPath("bookings 2000.mdb")
cnbook.open connstr, "", ""
select case UCase (Request.QueryString("view"))
Case "ALL"
TheMessage = "All Bookings"
sqltext = "SELECT * FROM newbookings"
Case Else
TheMessage = "Search Results"
sqltext = "SELECT * FROM newbookings"
sqltext = sqltext & " WHERE "
sqltext = sqltext & " LIKE '%" & varfind3 & "%'"
sqltext = sqltext & " AND '%" & varfind4 & "%'"
sqltext = sqltext & " AND '%" & varfind5 & "%'"
sqltext = sqltext & "ORDER by " & varsort
End Select
Response.Write sqltext
set rsbook = cnbook.Execute(sqltext)<<< this is line 39>>>>
thanks in advance.
Message #2 by "Kim Iwan Hansen" <kimiwan@k...> on Fri, 30 Nov 2001 22:49:56 +0100
|
|
you need to put which field should match each of the LIKEs..
SELECT * FROM newbookings WHERE field1 LIKE '%40%' AND field 2 LIKE '%2001%
etc.
-Kim
-----Original Message-----
From: tim.puffer@t... [mailto:tim.puffer@t...]
Sent: 30. november 2001 21:32
To: ASP Databases
Subject: [asp_databases] searching for multiple items in one database
I am trying to look for several items in one database. I think i am on
the write track ??? could someone take a look at my code and let me know
if i am close?
this is the response.write that it generates.
SELECT * FROM newbookings WHERE LIKE '%40%' AND '%2001%' AND '%bic%'ORDER
by
Here is my code.
<%
dim varIn, varFind1, varfind2,varfind3, varfind4, varfind5,
cnbook, connstr, theMessage, sqltext, rsbook, varsort, total
varsort= Request.Form("sort")
varIn = Request.form("in")
varFind1 = Request.form("find1")
varFind2 = Request.form("find2")
varFind3 = Request.form("find3")
varFind4 = Request.form("find4")
varFind5 = Request.form("find5")
response.write varFind1
response.write varFind2
response.write varFind3
response.write varFind4
response.write varFind5
' response.write varIn
' reponse.write varsort
' reponse.write total
set cnbook = server.createobject ("adodb.connection")
connstr = "driver={microsoft access driver (*.mdb)};" & _
"dbq=" & server.MapPath("bookings 2000.mdb")
cnbook.open connstr, "", ""
select case UCase (Request.QueryString("view"))
Case "ALL"
TheMessage = "All Bookings"
sqltext = "SELECT * FROM newbookings"
Case Else
TheMessage = "Search Results"
sqltext = "SELECT * FROM newbookings"
sqltext = sqltext & " WHERE "
sqltext = sqltext & " LIKE '%" & varfind3 & "%'"
sqltext = sqltext & " AND '%" & varfind4 & "%'"
sqltext = sqltext & " AND '%" & varfind5 & "%'"
sqltext = sqltext & "ORDER by " & varsort
End Select
Response.Write sqltext
set rsbook = cnbook.Execute(sqltext)<<< this is line 39>>>>
thanks in advance.
$subst('Email.Unsub')
Read the future with ebooks at B&N
http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid
=rn_ebooks
Message #3 by "PUFFER, TIM" <TIM.PUFFER@T...> on Fri, 30 Nov 2001 16:08:11 -0600
|
|
I would like to look in all of the fields for an instance of the search
items.
-----Original Message-----
From: Kim Iwan Hansen [mailto:kimiwan@k...]
Sent: Friday, November 30, 2001 3:50 PM
To: ASP Databases
Subject: [asp_databases] RE: searching for multiple items in one
database
you need to put which field should match each of the LIKEs..
SELECT * FROM newbookings WHERE field1 LIKE '%40%' AND field 2 LIKE '%2001%
etc.
-Kim
-----Original Message-----
From: tim.puffer@t... [mailto:tim.puffer@t...]
Sent: 30. november 2001 21:32
To: ASP Databases
Subject: [asp_databases] searching for multiple items in one database
I am trying to look for several items in one database. I think i am on
the write track ??? could someone take a look at my code and let me know
if i am close?
this is the response.write that it generates.
SELECT * FROM newbookings WHERE LIKE '%40%' AND '%2001%' AND '%bic%'ORDER
by
Here is my code.
<%
dim varIn, varFind1, varfind2,varfind3, varfind4, varfind5,
cnbook, connstr, theMessage, sqltext, rsbook, varsort, total
varsort= Request.Form("sort")
varIn = Request.form("in")
varFind1 = Request.form("find1")
varFind2 = Request.form("find2")
varFind3 = Request.form("find3")
varFind4 = Request.form("find4")
varFind5 = Request.form("find5")
response.write varFind1
response.write varFind2
response.write varFind3
response.write varFind4
response.write varFind5
' response.write varIn
' reponse.write varsort
' reponse.write total
set cnbook = server.createobject ("adodb.connection")
connstr = "driver={microsoft access driver (*.mdb)};" & _
"dbq=" & server.MapPath("bookings 2000.mdb")
cnbook.open connstr, "", ""
select case UCase (Request.QueryString("view"))
Case "ALL"
TheMessage = "All Bookings"
sqltext = "SELECT * FROM newbookings"
Case Else
TheMessage = "Search Results"
sqltext = "SELECT * FROM newbookings"
sqltext = sqltext & " WHERE "
sqltext = sqltext & " LIKE '%" & varfind3 & "%'"
sqltext = sqltext & " AND '%" & varfind4 & "%'"
sqltext = sqltext & " AND '%" & varfind5 & "%'"
sqltext = sqltext & "ORDER by " & varsort
End Select
Response.Write sqltext
set rsbook = cnbook.Execute(sqltext)<<< this is line 39>>>>
thanks in advance.
$subst('Email.Unsub')
Read the future with ebooks at B&N
http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid
=rn_ebooks
tim.puffer@t...
$subst('Email.Unsub')
Read the future with ebooks at B&N
http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid
=rn_ebooks
Message #4 by "Kim Iwan Hansen" <kimiwan@k...> on Fri, 30 Nov 2001 23:26:35 +0100
|
|
i guess you'll need to cast/convert each field that's not a string type to a
string type and then do the search on those fields.. i think that'll be the
easiest approach.
the LIKE function only works on string type fields.
-Kim
-----Original Message-----
From: PUFFER, TIM [mailto:TIM.PUFFER@T...]
Sent: 30. november 2001 23:08
To: ASP Databases
Subject: [asp_databases] RE: searching for multiple items in one datab
ase
I would like to look in all of the fields for an instance of the search
items.
-----Original Message-----
From: Kim Iwan Hansen [mailto:kimiwan@k...]
Sent: Friday, November 30, 2001 3:50 PM
To: ASP Databases
Subject: [asp_databases] RE: searching for multiple items in one
database
you need to put which field should match each of the LIKEs..
SELECT * FROM newbookings WHERE field1 LIKE '%40%' AND field 2 LIKE '%2001%
etc.
-Kim
-----Original Message-----
From: tim.puffer@t... [mailto:tim.puffer@t...]
Sent: 30. november 2001 21:32
To: ASP Databases
Subject: [asp_databases] searching for multiple items in one database
I am trying to look for several items in one database. I think i am on
the write track ??? could someone take a look at my code and let me know
if i am close?
this is the response.write that it generates.
SELECT * FROM newbookings WHERE LIKE '%40%' AND '%2001%' AND '%bic%'ORDER
by
Here is my code.
<%
dim varIn, varFind1, varfind2,varfind3, varfind4, varfind5,
cnbook, connstr, theMessage, sqltext, rsbook, varsort, total
varsort= Request.Form("sort")
varIn = Request.form("in")
varFind1 = Request.form("find1")
varFind2 = Request.form("find2")
varFind3 = Request.form("find3")
varFind4 = Request.form("find4")
varFind5 = Request.form("find5")
response.write varFind1
response.write varFind2
response.write varFind3
response.write varFind4
response.write varFind5
' response.write varIn
' reponse.write varsort
' reponse.write total
set cnbook = server.createobject ("adodb.connection")
connstr = "driver={microsoft access driver (*.mdb)};" & _
"dbq=" & server.MapPath("bookings 2000.mdb")
cnbook.open connstr, "", ""
select case UCase (Request.QueryString("view"))
Case "ALL"
TheMessage = "All Bookings"
sqltext = "SELECT * FROM newbookings"
Case Else
TheMessage = "Search Results"
sqltext = "SELECT * FROM newbookings"
sqltext = sqltext & " WHERE "
sqltext = sqltext & " LIKE '%" & varfind3 & "%'"
sqltext = sqltext & " AND '%" & varfind4 & "%'"
sqltext = sqltext & " AND '%" & varfind5 & "%'"
sqltext = sqltext & "ORDER by " & varsort
End Select
Response.Write sqltext
set rsbook = cnbook.Execute(sqltext)<<< this is line 39>>>>
thanks in advance.
$subst('Email.Unsub')
Read the future with ebooks at B&N
http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid
=rn_ebooks
tim.puffer@t...
$subst('Email.Unsub')
Read the future with ebooks at B&N
http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid
=rn_ebooks
$subst('Email.Unsub')
Read the future with ebooks at B&N
http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&categoryid
=rn_ebooks
|
|
 |