I recently asked a questtion on how o write a query and thankfully you guys answered me (Thank you)
Im working on a WML site so I need to pass the values from the query I found a way to do so (shown below in code) , but It didnt work.
<%
//this Query was provided earlier in the previous question.
string queryString = "select st.firstname + ' ' + st.lastname,se.year, c.coursename,c.NumberOfCredits,ri.mark from Students st inner join RegisteredIn ri on ri.StudentId=st.id inner join Semester se on se.id=ri.SemesterId inner join Courses c on c.id=se.id ";
the Way I found but didnt work
using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString))
{
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(queryString, connection);
command.Parameters.AddWithValue("@StudentId",StudentId);
connection.Open();
System.Data.SqlClient.SqlDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
reader.Read();
string _firstname = reader[0].ToString();
string _lastname = reader[1].ToString();
string _coursename = reader[2].ToString();
string _credits = reader[3].ToString();
string _mark = reader[4].ToString();
string url = string.Format("~/StudentInfo.aspx?StudentId={0}&firstname={1}&lastname={2}&coursename={3}&credits={4}&mark={5}", StudentId, _firstname, _lastname, _coursename, _credits, _mark);
Response.Redirect(url);
%>
The page reciving the paramaters will be somthing like
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="StudentInfo.aspx.cs" Inherits="StudentInfo" %>
<wml>
<card>
<p><% Response.Write(Request.Params["StudentId"]);%></p>
<p><b>firstname:</b> <% Response.Write(Request.Params["firstname"]);%></p>
<p><b>lastname:</b> <% Response.Write(Request.Params["lastname"]);%></p>
<p><b>coursename:</b> <% Response.Write(Request.Params["coursename"]);%></p>
<p><b>credits:</b> <% Response.Write(Request.Params["credits"]);%></p>
<p><b>Mark:</b> <% Response.Write(Request.Params["mark"]);%></p>
</card>
</wml>
the result will be somthing like
First Semester 2010
Student : Arin Rizk
Course Name No. of Credit Mark
AAA 3 65
BBB 3 23
CCC 3 65
DDD 3 58
EEE 3 70
Your GPA for this semster is 3.12
My Questions are: - How to extract the values from the query and into the URL ? - How I will display multiple values in WML or in ASP ? (as the results will be multiple lines and of values)
Thank you in advance