Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 156
  • Last Modified:

Writting SQL statment for "Search Result page" in Dream mx.

Hi everybody

Thanks for your time.
 I have a website connected to a table in Access xp ,on all pages which has been created from template i have put a textfiled box(with post method), for searching Title of book in table,i have also a SearchResultpage.cfm which must reterive dara from table,and for this page have created a recordset ,but for writting its sql i have problem,please help .

Thanks again for your time
mostaghassi
0
MOSTAGHASSI
Asked:
MOSTAGHASSI
  • 7
  • 5
1 Solution
 
zombeenCommented:
something like this...

strsql = "select * from <table name> where title like '%" & request.form("book_title") & "%'"

Thanks
Zombeen

0
 
MOSTAGHASSIAuthor Commented:
Hi zombeen

Thanks for your comment.
Please let me know,what is "book_title"? is it the name of textbox?or name of form? i tested with these but it doesn't reterive data ofcourse i donot recieve error also,and i think the first and last qutation(") is not nessecery?.

thanks again for your time.
mostaghassi

0
 
zombeenCommented:
book_title is the name of the text-box. the quotes are necessary if you are checking for a string type of field, which i think is the case with your field (title)

thanks
Zombeen
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
MOSTAGHASSIAuthor Commented:
Hi

As you know ,in dream mx when we create a recordset for a page and click on it ,open a box for writing sql,i writ this statment ,but  when test it it reterives no data.


SELECT *
FROM BookMainTable
WHERE deleting_a_record=yes and title like '%"& request.form("textfield2")
&"%'
ORDER BY title asc

thanks
0
 
MOSTAGHASSIAuthor Commented:
Hi

As you know ,in dream mx when we create a recordset for a page and click on it ,open a box for writing sql,i writ this statment ,but  when test it it reterives no data.


SELECT *
FROM BookMainTable
WHERE deleting_a_record=yes and title like '%"& request.form("textfield2")
&"%'
ORDER BY title asc

thanks
0
 
MOSTAGHASSIAuthor Commented:
Hi

As you know ,in dream mx when we create a recordset for a page and click on it ,open a box for writing sql,i writ this statment ,but  when test it it reterives no data.


SELECT *
FROM BookMainTable
WHERE deleting_a_record=yes and title like '%"& request.form("textfield2")
&"%'
ORDER BY title asc

thanks
0
 
zombeenCommented:
>>>> SELECT *
FROM BookMainTable
WHERE deleting_a_record=yes and title like '%"& request.form("textfield2")
&"%'
ORDER BY title asc

what purpose is deleting_a_record solving here. What type of field it is. if it is not numeric as it appears, u wshd include quotes ard the field

Thanks
zombeen
0
 
MOSTAGHASSIAuthor Commented:
deleting_a_record is a logic field in my table,and when it is=yes it means that the records in that line can reterive,if it is =no then the sql statement ignore that record and it brings the records which are "yes".

Thanks
mostaghassi
0
 
zombeenCommented:
r u sure u dont want to include them in quotes ...
'yes' in place of yes

Thanks
Zombeen
0
 
MOSTAGHASSIAuthor Commented:
I have several pages that its sql recordset is like this:

SELECT *
FROM BookMainTable
WHERE deleting_a_record=yes and "subject" = 'Miscellanous'
ORDER BY title asc

and work properly,and regarding your suggestion i used quot and even i deleted this part(deleting_a_record=yes )
and wrot like this :

SELECT *
FROM BookMainTable
WHERE title like '%"& request.form("textfield2")
&"%'
ORDER BY title asc

but it doesn't work.

thanks
mostaghassi
0
 
zombeenCommented:
do you get any kind of errors...

can u print out the sql statement to find out wot values are being sent to sql statement (use response.write )

try printing out the recordcount of the recordset

Thanks
Zombeen
0
 
MOSTAGHASSIAuthor Commented:
Hi

I found what is the problem,since i use coldfusion mx as server programming it doesn't need "Request" and the codes must be like bellow,

SELECT *
FROM BookMainTable
WHERE deleting_a_record=yes and Title like '%#form.textfield2#%'

and i have defied for "page paramer" like this:
"form.textfield2" ,it works and reterive data but since i have used navigation bar(first-provious-next-last),these navigation does not work properly can u help?
thanks
mostaghassi
0
 
NetminderCommented:
Points refunded and question closed.

Netminder
EE Admin
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now