Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 02, 2012 10:39 AM by BoEneD
Feb 01, 2012 11:23 AM|LINK
I surfed on the web the hole day and didn't find anything that would work on my problem :(
On my first page I got a list with all the news titles... now i want to display a few more details on that specific news by clicking on the topic and it should be open on a second page. The details are all saved in a Access database... reading the database
and everything works fine.. but how do I pass variables from that first page to second, so that I can make the right sql code to get the right news.. here some code ;)
Here I'm filling the variable for passing to the next page:
<td width="80%"><a href="\News.cshtml?ID=@thisReader["ID"]">@thisReader["Titel"]</a></td>
on the second page i inserted :
ID = Request.QueryString("ID");
But now he is giving me a "CS1026: ) erwartet." compiler error.. hope somebody can help me out
Feb 01, 2012 11:54 AM|LINK
Are you getting any values in "@thisReader["ID"]", "@thisReader["Titel"]" and "@thisReader["Enddatum"]" ?
Feb 01, 2012 12:00 PM|LINK
yep.. ID is getting filled with "3" f.e. I got a access database connected, where the page reads all its content.. and the ID is the primary key of that DB.
Feb 01, 2012 12:08 PM|LINK
So is any value getting displayed in this:
Feb 01, 2012 01:52 PM|LINK
yep... the date is displayed... exactly the date I wrote in the database... :)
but the date isn't the important thing, the important thing is, that the variable i send to the next page, doesnt really arrive there ^^
Feb 02, 2012 04:21 AM|LINK
Ok. I was just trying to investigate whether values are getting fetched from the DB or not.
As values are getting fetched, you may try this one:
Feb 02, 2012 05:12 AM|LINK
that doesn't work.. i tried your code.. but when you click on the link on the test page it didn't even fill the the text after "?ID=". In the address bar stands then: http://localhost:2493/News.cshtml?ID=
But in fact when I let it the it is (<a href="\News.cshtml?ID=@thisReader["ID"]">@thisReader["Titel"]</a>) the adress bar gives me following adress:
thats how i want it to be. The problem is the second page.. where i want to work with the variable (here the ID (as you can see the "3" in the adress)).
But he gives me a mistake message
Zeile 17: // Open Connection object
Zeile 18: thisConnection.Open();
Zeile 19: ID = Request.QueryString("@thisReader["ID"]");
Zeile 20: // Create SQL command object on this connection
Zeile 21: var thisCommand = thisConnection.CreateCommand();
with the compiling error: CS1026: ) expected.
Feb 02, 2012 05:17 AM|LINK
ID = Request.QueryString("@thisReader["ID"]");
Ohh, yes !! there is small mistake..
Instead of this, try below code:
ID = Request.QueryString("ID");
Feb 02, 2012 05:34 AM|LINK
okay i tried, but then he told me, the variable ID is no declarated so I inserted var ID =""; but now he the compiler tells me
Compiler error: CS1955: the not available member "System.Web.HttpRequestBase.QueryString" cannot be used like a method.
I'm not quite sure, what he wants to tell me with that xD
Feb 02, 2012 05:40 AM|LINK
Replace parenthesis with square brackets: ["ID"]