Update SELECT statement with form field? - Posted (1762 Views)
Junior Member
Lon2
Posts: 151
151
Anyone know how to make an SQL SELECT statement updateable by a form field entry? For example:

Code:
rsTopics.Source = "SELECT * FROM Topics WHERE TopicID = 365"
I would like make the TopicID equals part (365) updateable by just typing the number in a form on an ASP page and clicking submit to update the page with the new TopicID number.<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Junior Member
Lon2
Posts: 151
151
Thanks a lot for your time on that, cripto, it's very much appreciated! [^]
Is there an easy way to toggle between 2 connection strings on one page? For example; clicking a buttin to set the following connection string to one or the other:
Code:
rsComments.Source = "SELECT * FROM Comments WHERE Approved = False"

rsComments.Source = "SELECT * FROM Comments WHERE TopicID="& intTPID
I think I may be doing this the hard way...
Or, run 2 queries on the same page? For example:
Code:
rsComments.Source = "SELECT * FROM Comments WHERE "& Option1" OR "& Option2"

Option1 = Approved = False" Option2 = TopicID="& intTPID
I guess I'm asking how to run 2 different queries on the same connection (on the same page) so I don't have to duplicate everything... and will they work simultaniously?<
Posted
Advanced Member
Etymon
Posts: 2396
2396
Take a look throughout the Snitz forum base code, and you will find many examples of what you want. smile<
Posted
Junior Member
Lon2
Posts: 151
151
Ok, I got it working somewhat the way I need, and I think I saved a ton of work. Here's what I did:
Code:
<% 
dim intTPID
intTPID = Request.Form("ManImgID")

set rsComments = Server.CreateObject("ADODB.Recordset")
rsComments.ActiveConnection = MM_connImageGallery_STRING

if trim(intTPID) <> "" and isNumeric(intTPID) = true then
rsComments.Source = "SELECT * FROM Comments WHERE TopicID="& intTPID

else
rsComments.Source = "SELECT * FROM Comments WHERE Approved = False"
end if

rsComments.CursorType = 0
rsComments.CursorLocation = 2
rsComments.LockType = 3
rsComments.Open()
rsComments_numRows = 0
%>
On the page I have a form field. When it's blank it shows Comments Not Approved (Approved = False) and when I enter a TopicID and submit it shows Topic Comments (TopicID="& intTPID). I just hit the submit button with a blank field to get back to Comments Not Approved.
Does anyone see any problems with the way I'm doing this?<
Posted
Junior Member
Lon2
Posts: 151
151
I guess not.
Thanks anyway!<
You Must enter a message