Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: to retrieve data from the data base ,by passing parameter through a link.


Message #1 by omkarj@h... on Wed, 14 Feb 2001 12:11:16
I have an asp file which retrieves data from a database and shows it in a 

table format on html file .

Let us say there are 3  columns in this table ...

Eg.

Name    no.    Total.



Name has a link ... ie. If I click on a particular name .it gives me whole

data from that  data base for that name and its unique rollno.



 ie.  I have to pass on roll no. as field for the query...to another asp 

file...



if i use querystring it shows the data i have paased in the address bar of 

the browser.



after paasing the value to the next file how to get the value and open the 

data base.







Message #2 by Imar Spaanjaars <Imar@S...> on Wed, 14 Feb 2001 13:22:26 +0100
You can retrieve the information through the QueryString collection.



Suppose this is the address in your addressbar:



http://localhost/mypage.asp?ID=123



Then in mypage.asp you can do this:



Dim iMyID

iMyID = Request.QueryString("ID")



If len(iMyID) > 0 'then  a value was actually passed

         Response.Write(iMyID)

         ' Get the data from the database based on the ID

else

         Response.Write("I am sorry, you have to pass a valid ID to me")

end if





HtH



Imar



At 12:11 PM 2/14/2001 +0000, you wrote:

>I have an asp file which retrieves data from a database and shows it in a

>table format on html file .

>Let us say there are 3  columns in this table ...

>Eg.

>Name    no.    Total.

>

>Name has a link ... ie. If I click on a particular name .it gives me whole

>data from that  data base for that name and its unique rollno.

>

>  ie.  I have to pass on roll no. as field for the query...to another asp

>file...

>

>if i use querystring it shows the data i have paased in the address bar of

>the browser.

>

>after paasing the value to the next file how to get the value and open the

>data base.



Message #3 by omkarj@h... on Wed, 14 Feb 2001 12:35:51
how do i specify the id...

is it the id of the element which holds the value..which i want to send to 

next file



eg..

<table >

<tr><td id=1>xyz</td><tr>



i want to pass xyz as value to the next file..





















> You can retrieve the information through the QueryString collection.

> 

> Suppose this is the address in your addressbar:

> 

> http://localhost/mypage.asp?ID=123

> 

> Then in mypage.asp you can do this:

> 

> Dim iMyID

> iMyID = Request.QueryString("ID")

> 

> If len(iMyID) > 0 'then  a value was actually passed

>          Response.Write(iMyID)

>          ' Get the data from the database based on the ID

> else

>          Response.Write("I am sorry, you have to pass a valid ID to me")

> end if

> 

> 

> HtH

> 

> Imar

> 

> At 12:11 PM 2/14/2001 +0000, you wrote:

> >I have an asp file which retrieves data from a database and shows it in 

a

> >table format on html file .

> >Let us say there are 3  columns in this table ...

> >Eg.

> >Name    no.    Total.

> >

> >Name has a link ... ie. If I click on a particular name .it gives me 

whole

> >data from that  data base for that name and its unique rollno.

> >

> >  ie.  I have to pass on roll no. as field for the query...to another 

asp

> >file...

> >

> >if i use querystring it shows the data i have paased in the address bar 

of

> >the browser.

> >

> >after paasing the value to the next file how to get the value and open 

the

> >data base.

> 

Message #4 by Imar Spaanjaars <Imar@S...> on Wed, 14 Feb 2001 13:52:54 +0100
Make sure that you pass the Unique ID from the data from the database:



If this is your database:



Name            no.             Total.

John            123             1200

Jane            128             1000



Then I assume that no. is the unique key in the database. That is what you 

want to pass:



' This is your recordset loop, I asume....

do while not Recordset.EOF

         Response.Write("<TR><TD><a href=""myPage.asp?ID=" & 

Recordset.Fields.Item("no") & """>" & Recordset.Fields.Item("Name") & 

"</a></td></tr>")

         Recordset.MoveNext()

loop





If all goes well, this will write the following to the browser:



<TR><TD><a href="myPage.asp?ID=123">John</a></td></tr>

<TR><TD><a href="myPage.asp?ID=128">Jane</a></td></tr>



Now by clicking on either John or Jane, you'll be transferred to 

myPage.asp. There you can retrieve the ID again to query the details for 

John or Jane.



HtH



Imar





At 12:35 PM 2/14/2001 +0000, you wrote:

>how do i specify the id...

>is it the id of the element which holds the value..which i want to send to

>next file

>

>eg..

><table >

><tr><td id=1>xyz</td><tr>

>

>i want to pass xyz as value to the next file..

>

>

>

>

>

>

>

>

>

>

> > You can retrieve the information through the QueryString collection.

> >

> > Suppose this is the address in your addressbar:

> >

> > http://localhost/mypage.asp?ID=123

> >

> > Then in mypage.asp you can do this:

> >

> > Dim iMyID

> > iMyID = Request.QueryString("ID")

> >

> > If len(iMyID) > 0 'then  a value was actually passed

> >          Response.Write(iMyID)

> >          ' Get the data from the database based on the ID

> > else

> >          Response.Write("I am sorry, you have to pass a valid ID to me")

> > end if

> >

> >

> > HtH

> >

> > Imar



Message #5 by omkarj@h... on Wed, 14 Feb 2001 13:13:43
thanks it works......







> Make sure that you pass the Unique ID from the data from the database:

> 

> If this is your database:

> 

> Name            no.             Total.

> John            123             1200

> Jane            128             1000

> 

> Then I assume that no. is the unique key in the database. That is what 

you 

> want to pass:

> 

> ' This is your recordset loop, I asume....

> do while not Recordset.EOF

>          Response.Write("<TR><TD><a href=""myPage.asp?ID=" & 

> Recordset.Fields.Item("no") & """>" & Recordset.Fields.Item("Name") & 

> "</a></td></tr>")

>          Recordset.MoveNext()

> loop

> 

> 

> If all goes well, this will write the following to the browser:

> 

> <TR><TD><a href="myPage.asp?ID=123">John</a></td></tr>

> <TR><TD><a href="myPage.asp?ID=128">Jane</a></td></tr>

> 

> Now by clicking on either John or Jane, you'll be transferred to 

> myPage.asp. There you can retrieve the ID again to query the details for 

> John or Jane.

> 

> HtH

> 

> Imar

> 

> 

> At 12:35 PM 2/14/2001 +0000, you wrote:

> >how do i specify the id...

> >is it the id of the element which holds the value..which i want to send 

to

> >next file

> >

> >eg..

> ><table >

> ><tr><td id=1>xyz</td><tr>

> >

> >i want to pass xyz as value to the next file..

> >

> >

> >

> >

> >

> >

> >

> >

> >

> >

> > > You can retrieve the information through the QueryString collection.

> > >

> > > Suppose this is the address in your addressbar:

> > >

> > > http://localhost/mypage.asp?ID=123

> > >

> > > Then in mypage.asp you can do this:

> > >

> > > Dim iMyID

> > > iMyID = Request.QueryString("ID")

> > >

> > > If len(iMyID) > 0 'then  a value was actually passed

> > >          Response.Write(iMyID)

> > >          ' Get the data from the database based on the ID

> > > else

> > >          Response.Write("I am sorry, you have to pass a valid ID to 

me")

> > > end if

> > >

> > >

> > > HtH

> > >

> > > Imar

> 


  Return to Index