hello every one
i am working on a single asp.net page , i am using ext js 4 ,and using grid control .my task is to get data from mssql server and show that data in that ext grid, for this i am using webservice , here is a code of my web service
now how can i show my data in grid using this webservice , please help me , as i am very new in thisCode:using System; using System.Collections.Generic; using System.Linq; using System.Web.Services; using System.IO; using System.Text; using System.Collections; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Web; using System.Web.Script.Services; using System.Web.Script.Serialization; using System.Runtime.Serialization; namespace JSWorking { /// <summary> /// Summary description for WebService2 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class WebService2 : System.Web.Services.WebService { HttpContext postedContext = HttpContext.Current; [WebMethod (EnableSession = true )] [ScriptMethod (ResponseFormat = ResponseFormat .Json ,UseHttpGet = true ,XmlSerializeString = false )] public List <Object[]> GetData ( string Name , int PhoneNo , int CellNo , int IDNo , string Advance ) { string strCN = "Data Source=waqas\\sqlexpress2;Initial Catalog=myDB;User Id=waqas;Password=patanahi;"; SqlConnection CN = new SqlConnection(strCN); CN.Open(); string strQuery = "Select Name,PhonenO,CellNo,IDNo,Advance from Students"; SqlCommand cmd = new SqlCommand(strQuery,CN); cmd.CommandType = CommandType.Text; SqlDataReader reader = cmd.ExecuteReader(); List<Object[]> myArray = new List<object[]>(); try { while (reader.Read()) { Object[] values = new Object[reader.FieldCount]; int fieldCount = reader.GetValues(values); myArray.Add(values); } return myArray; } catch (Exception ex) { throw ex; } finally { reader.Close (); reader.Dispose (); cmd.Dispose (); CN.Close (); CN.Dispose (); } } } }
any help will be greatly appreciated
Best Regards
M.Waqas Aslam



Reply With Quote

Bookmarks