![]() |
Query With a C# Variable?
Hiya
I was wondering if someone could help me out here, please? Big Smile I'm creating a forum, my threads page has the following query: SELECT * FROM [threads] WHERE ([forum_name] = ?) ORDER BY [time_created] DESC The "?" (control value) is the sub-forum which the thread is linked to. Example: List of Forums: - Introduce Yourself - The Lounge - Another Thread - Blah Blah Blah User clicks on The Lounge, loads thread.aspx where Query: SELECT * FROM [threads] WHERE ([forum_name] = ?) ORDER BY [time_created] DESC runs ------------------------------------------------------------------------------------------------------------------------------------------------ Now the page with "The Lounge" threads loads, and I store the querystring into a variable string forum_name = Page.Request.QueryString["forum_name"]; Page.Response.Write("Now browsing the threads about " + forum_name); Now the user clicks "New Thread" button, and is presented with a form to fill out. Instead of typing the name of the forum that their thread is to be featured in (i.e. "The Lounge") I would like it to automatically have this filled in, based upon where they came from. My Insert query then looks like this: Insert Into threads ([thread_name], [thread_author], [forum_name], [time_created]) Values(?,?,?,?)" But I'm getting an error saying "No value given for one or more required parameters." So I think the variable isn't passing into the query. Do you know why this might be? Basically, how do I incorporate the value stored in that variable, into the query? Thanks a lot! Kind Regards, Steven |
i think your in the wrong section.
|
There is no C# version, so I figured this would be the next best place.
If a mod wants to move it to a more relevant section, feel free. ^^ |
To simplify, I want to do something like the following:
PHP Code:
|
You have the easy option and an advanced option. Your easy option is that you already have a variable "forum_name" that has your forum name, so why not pass this on to your new thread page.
People click view lounge and it goes to the page view.aspx?name=viewlounge and you query that paramter am I correct? Then from that page you call /newthread.aspx?name=viewlounge and just on your page_load event, just fill the textbox in with that parameter. |
In the page load event set a hidden field to the value of that variable then set that hidden fields contents to be the query param. Or a bit more secure way is to set that variable as a session variable in the page load then set that parameter as a session param and get it that way.
|
| All times are GMT. The time now is 11:41 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0