Getting variable from url

  • Picceta
  • Born
  • Born
  • Picceta
  • Posts: 1

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6230
  • Loc: South-Africa

Post 3+ Months Ago

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")

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 136 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.