Getting variable from url

  • Picceta
  • Born
  • Born
  • No Avatar
  • Joined: Mar 27, 2010
  • Posts: 1
  • Status: Offline

Post March 27th, 2010, 3:28 am

Basically I have a product system where on one page it pulls each product from the database, and assigns individual url's for the next aspx page.

But I can't figure out how to pull that variable from the url so that it can display the correct product info on the viewing product aspx page.

ASP Code: [ Select ]
<script runat="server">
sub Page_Load
dim msaccessconnect,query,databasecommunication,readdatabase
        msaccessconnect = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("Database.mdb"))
        msaccessconnect.Open()
        dim id As
        query = "SELECT * FROM Products WHERE Product_ID="
databasecommunication=New OleDbCommand(query,msaccessconnect)
readdatabase=databasecommunication.ExecuteReader()
        Products.DataSource = readdatabase
        Products.DataBind()
readdatabase.Close()
msaccessconnect.Close()
end sub
</script>
  1. <script runat="server">
  2. sub Page_Load
  3. dim msaccessconnect,query,databasecommunication,readdatabase
  4.         msaccessconnect = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("Database.mdb"))
  5.         msaccessconnect.Open()
  6.         dim id As
  7.         query = "SELECT * FROM Products WHERE Product_ID="
  8. databasecommunication=New OleDbCommand(query,msaccessconnect)
  9. readdatabase=databasecommunication.ExecuteReader()
  10.         Products.DataSource = readdatabase
  11.         Products.DataBind()
  12. readdatabase.Close()
  13. msaccessconnect.Close()
  14. end sub
  15. </script>


I'd really appreciate any help anyone can give me! Thanks!
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 27th, 2010, 3:28 am

  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Joined: Mar 12, 2007
  • Posts: 6228
  • Loc: South-Africa
  • Status: Offline

Post April 14th, 2010, 7:15 am

let's say your URL is mywebsite.com?product=101, you would then do something like the following to get the 101 from that URL:

Code: [ Select ]
Dim product as String = Request.QueryString("product")
Let's leave all our *plum* where it is and go live in the jungle ...

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 183 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.