using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Script.Services; using System.Configuration; using System.Data; using System.Data.SqlClient; using Kovair.Interface; namespace Kovair.StudentService { /// <summary> /// Summary description for StudentWebService /// </summary> [WebService(Namespace = "http://Kovair.StudentService/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] [System.Web.Script.Services.ScriptService] public class StudentWebService : System.Web.Services.WebService { [WebMethod] [ScriptMethod(ResponseFormat=ResponseFormat.Json)] public StudentMark GetStudentDetail(StudentRecord stu) { string connStr = ConfigurationManager.ConnectionStrings["KovairSiteConnectionString"].ToString(); SqlConnection conn = new SqlConnection(connStr); int roll = stu.RollNo; SqlCommand comm = new SqlCommand(); comm.CommandText = "SELECT R.RollNo, M.Marks From dbo.StuMark M INNER JOIN dbo.StuRec R ON M.RollNo = R.RollNo WHERE R.RollNo = @rollNo"; comm.Parameters.Add(new SqlParameter("@rollNo", SqlDbType.Int)).Value = roll; comm.Connection = conn; SqlDataAdapter da = new SqlDataAdapter(comm); var ds = new DataSet(); conn.Open(); da.Fill(ds, "StudentDetailRecord"); conn.Close(); string marks = String.Empty; if (ds.Tables != null) { int recordCount = ds.Tables["StudentDetailRecord"].Rows.Count; if (recordCount > 0) { DataTable dtab = ds.Tables["StudentDetailRecord"]; marks = dtab.Rows[0]["Marks"].ToString(); } } var sm = new StudentMark(); sm.RollNo = stu.RollNo; sm.Mark= Convert.ToInt32(marks); return sm; } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)