Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Passing value to next page

Author  Topic 

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2008-02-15 : 07:07:32
Hi i have a SQL stored procedure on my asp page where am returning sup_code and supplier Name.

This is how i call my sp

cmd.CommandType = adCmdStoredProc
cmd.CommandText = "ChangeSupplier"

I like to know how i can access the supplier name and store it and then. I want to pass the supplier name to my next page so i can display it as a heading.

Am not an asp developer just asked to do this task any help would be great thanks..

georgev
Posting Yak Master

122 Posts

Posted - 2008-02-15 : 08:21:53
What you have to do is open what is called a recordset. You can then iterate (go through one at a time) over the results and do what you like with them (i.e. assign them to variables).

Take a look at the ADO tutorials on http://www.w3schools.com/ado/ado_recordset.asp


George
<3Engaged!
Go to Top of Page

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2008-02-15 : 10:09:49
Sorry i just had another look at the asp code i do display my sup_name in my drop down list option is there any way i can store it as i only want to display the supplier name from which the supplier code i select in the drop down list. The supplier code i select is passed into the next page



<select name="ChangedSupplier">
<option value="">-- All --</option>
<% If bResults Then %>
<% While NOT Results.EOF %>

<option value="<%=Results("sup_code")%>"> <% IF sSelectedValue <> "" THEN IF CInt(Results("sup_code")) <> CInt (sSelectedValue) THEN Response.write "" ELSE Response.Write "selected" END IF END IF %>><%=Results("sup_code")%> - <%=Results("sup_name")%></option>

<%Results.MoveNext %>
<%Wend %>
<%End If %>
</select>


Go to Top of Page

georgev
Posting Yak Master

122 Posts

Posted - 2008-02-17 : 11:05:00
Here's some pseduocode for what you want
[CODE]
Assign pased value to a variable
Build your SQL string using the value passed
" SELECT someField" & _
" FROM someTable" & _
" WHERE thisField = '" & thePassedValue & "'"
Create a recordset object
Open recordset of your SQL
Cycle through the records and display
While Not yourRecordsetObject.EOF
For i = 0 To Ubound(yourRecordsetObject)
Reponse.Write(yourRecordsetObject.Fields(i).Value)
Next i
yourRecordsetObject.MoveNext
Loop
Close your recordset and connection
[/CODE]


George
<3Engaged!
Go to Top of Page

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2008-02-27 : 07:58:09
Hey sorry about this but am not a asp developer and know very little about asp i mostly do reporting so i know a bit of sql.. Would it be possible for you to give me some more help with this. I understand the pseduocode logic but coding it is a different ball game..
Thanks
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-02-27 : 08:43:08
You should find a basic book on ASP, or some tutorials online. No one here can explain via forum posts how to write an entire ASP program from scratch if you don't know the basics. Not only that, but you'll be worse off since you'll only know bits and pieces and never get the big picture. Spend a few hours, read some tutorials online, look into a book, you'll be much better off for it.

http://www.w3schools.com/asp/default.asp
http://www.asptutorial.info/
http://www.tutorialized.com/tutorials/ASP/1
http://www.tizag.com/aspTutorial/
http://www.google.com/search?q=asp+tutorials

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-02-27 : 08:43:52
quote:
Originally posted by georgev

Here's some pseduocode for what you want
[CODE]
Assign pased value to a variable
Build your SQL string using the value passed
" SELECT someField" & _
" FROM someTable" & _
" WHERE thisField = '" & thePassedValue & "'"
Create a recordset object
Open recordset of your SQL
Cycle through the records and display
While Not yourRecordsetObject.EOF
For i = 0 To Ubound(yourRecordsetObject)
Reponse.Write(yourRecordsetObject.Fields(i).Value)
Next i
yourRecordsetObject.MoveNext
Loop
Close your recordset and connection
[/CODE]


George
<3Engaged!



George -- never, ever concatenate strings like this -- always, always, always use ADO parameters.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -