The Forum has been Updated
The code has been upgraded to the latest .NET core version. Please check instructions in the Community Announcements about migrating your account.
Anyone know how to make an SQL SELECT statement updateable by a form field entry? For example:
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.<
Code:
rsTopics.Source = "SELECT * FROM Topics WHERE TopicID = 365"
Posted
Originally posted by Lon2
Anyone know how to make an SQL SELECT statement updateable by a form field entry? For example:Code: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.rsTopics.Source = "SELECT * FROM Topics WHERE TopicID = 365"
Take a look at post.asp and post_info.asp to see how they work together. What you are appearing to want done is to have your 365 become the catcher's mit for the form value like this TopicID = Request.Form("Topic_ID") ... so on post.asp look for a form value like name=""TOPIC_ID"" and then look on post_info.asp to see how that value is caught and processed (look for TopicID = " & cLng(Request.Form("Topic_ID")) & ").
Note, for a new topic, you will not see the topic_id value on the post.asp side because it has not been created yet, so look for name=""TOPIC_ID"" type=""hidden"" value=""" & strRqTopicID & """ where you find the name=""Method_Type"" type=""hidden"" value=""Reply"" or name=""Method_Type"" type=""hidden"" value=""EditReply"" or name=""Method_Type"" type=""hidden"" value=""EditTopic"" parts of the form on post.asp. That is where you will find the beginning of your question. How it is processed in post_info.asp is where you will find the answer to your question.
Last edited by Etymon on 06 December 2008, 23:44
Posted
You could also do it as a variable passed in a query expression.
At the beginning of your "topic.asp", add this:
or, to use a simple variable from a form:
Note: You'll need to change the five hyphen "-" characters to the name of your form field representing the topic ID.
For both/either of the cases above, change your line of code to say:
Thanks to Etymon for the table/variable correction - don't know where my mind was.<
Code:
dim intTPID
intTPID=server.htmlencode(request.QueryString)
or, to use a simple variable from a form:
Code:
dim intTPID
intTPID=request.form("-----")
Note: You'll need to change the five hyphen "-" characters to the name of your form field representing the topic ID.
For both/either of the cases above, change your line of code to say:
Code:
rsTopics.Source = "SELECT * FROM " & strActivePrefix & "Topics WHERE Topic_ID = " & intTPID
Thanks to Etymon for the table/variable correction - don't know where my mind was.<
Last edited by Carefree on 08 December 2008, 19:33
Posted
Posted
Thanks for the answers!
I did what Carefree suggested:And get the following error:
Syntax error (missing operator) in query expression 'TopicID ='.<
I did what Carefree suggested:
Code:
rsTopics.Source = "SELECT * FROM Topics WHERE TopicID =" & intTPID
and
dim intTPID
intTPID=request.form("ManualTopicID")
and
<form action="pend_topics.asp" method="post" name="ManualTopicID"><input type="text" size="10">
<input type="submit" name="Submit2" value="Submit">
</form>Syntax error (missing operator) in query expression 'TopicID ='.<
Posted
The field you are querying should be topic_id<
Posted
I'm sorry I'm not following you, Etymon...
When I manually write this: and upload it to the server, the page works correctly and shows all responses to the topic. When I write this:With the seperate dim statement and form, I get the error listed aboved. What am I doing wrong?
<
When I manually write this:
Code:
rsTopics.Source = "SELECT * FROM Topics WHERE TopicID = 365Code:
rsTopics.Source = "SELECT * FROM Topics WHERE TopicID =" & intTPID<
Posted
Unless you have a table structure that is different from a standard Snitz FORUM_TOPICS table ...
rsTopics.Source = "SELECT * FROM Topics WHERE TopicID =" & intTPID
should be:
rsTopics.Source = "SELECT * FROM " & strActivePrefix & "Topics WHERE Topic_ID = " & intTPID
or:
rsTopics.Source = "SELECT * FROM FORUM_Topics WHERE Topic_ID = " & intTPID<
rsTopics.Source = "SELECT * FROM Topics WHERE TopicID =" & intTPID
should be:
rsTopics.Source = "SELECT * FROM " & strActivePrefix & "Topics WHERE Topic_ID = " & intTPID
or:
rsTopics.Source = "SELECT * FROM FORUM_Topics WHERE Topic_ID = " & intTPID<
Last edited by Etymon on 08 December 2008, 19:06
Posted
Are you trying to make it so that folks can search for a Topic ID from a form?<
Posted
Sorry but this doesn't have anything to do with Snitz forums or Snitz code, hence the reason I started this topic in the "Code Support: ASP (Non-Forum Related)" forum. I was just using examples similar to Snitz in hopes it would be easier understood. Sorry for the confusion!
I should also clarify that the form, where the TopicID (365) is entered, is not accessible to anyone on the site. It is on an ASP page with a login for my access only.
Hope this doesn't discourage anyone from helping me further. I'm still stumped.<
I should also clarify that the form, where the TopicID (365) is entered, is not accessible to anyone on the site. It is on an ASP page with a login for my access only.
Hope this doesn't discourage anyone from helping me further. I'm still stumped.<
Posted
Then we're back to ALMOST where we started.
Using a variable from a form:
Note: You'll need to change the five hyphen "-" characters to the name of your form field representing the topic ID.
Change your line of code to say:
This should work. Your error is in using the FORM's name instead of the FIELD's name.<
Using a variable from a form:
Code:
dim intTPID
intTPID=request.form("-----")
Note: You'll need to change the five hyphen "-" characters to the name of your form field representing the topic ID.
Change your line of code to say:
Code:
rsTopics.Source = "SELECT * FROM Topics WHERE TopicID = " & intTPID
This should work. Your error is in using the FORM's name instead of the FIELD's name.<
Last edited by Carefree on 09 December 2008, 08:49
Email Member
Message Member
Post Moderation
FileUpload
If you're having problems uploading, try choosing a smaller image.
Preview post
Send Topic
Loading...