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.
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 = adCmdStoredProccmd.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! |
|
|
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> |
|
|
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 variableBuild your SQL string using the value passed " SELECT someField" & _ " FROM someTable" & _ " WHERE thisField = '" & thePassedValue & "'"Create a recordset objectOpen recordset of your SQLCycle 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 LoopClose your recordset and connection[/CODE] George<3Engaged! |
|
|
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 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
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 variableBuild your SQL string using the value passed " SELECT someField" & _ " FROM someTable" & _ " WHERE thisField = '" & thePassedValue & "'"Create a recordset objectOpen recordset of your SQLCycle 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 LoopClose your recordset and connection[/CODE] George<3Engaged!
George -- never, ever concatenate strings like this -- always, always, always use ADO parameters.- Jeffhttp://weblogs.sqlteam.com/JeffS |
|
|
|
|
|