SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation urgent help needed

    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
    Code:
    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 ();
                }
                }
            }
        }
    now how can i show my data in grid using this webservice , please help me , as i am very new in this

    any help will be greatly appreciated

    Best Regards

    M.Waqas Aslam

  2. #2
    SitePoint Zealot behati's Avatar
    Join Date
    Feb 2012
    Location
    Copenhagen, Denmark
    Posts
    152
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Is there any particular reason to use WebSource? A standard .NET DataSource should do the trick, and it comes with a simple Wizard in Visual Studio.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •