Tuesday, July 24, 2012

Thursday, June 7, 2012

OverLoading in WebServices and WCF

Binding Generic List<> Class to the Gridview using DataReader or Datatable

Here now we will fetch the data of a table from Database and bind it to Gridview using ListClass.

First Create a Class

public class Buzz
    {
        private string title;


        public string Title
        {
            get { return title; }
            set { title = value; }
        }


        private string desc;


        public string Desc
        {
            get { return desc; }
            set { desc = value; }
        }
    }


    public class BuzzList : List<Buzz>
    { }


In the above Class Buzz,it takes to members title and description.And also we can see another class BuzzList which is inherited from List<Buzz>


Now in the PageLoad

SqlConnection con = new SqlConnection("ur db connectionstring parameters");
 SqlCommand cmd = new MySqlCommand("select * from BUZZ", con);
 //BUZZ is the table in Database
  con.Open();
        try
        {
            BuzzList objBuzzList = new BuzzList();
            
           SqlDataReader dr = cmd.ExecuteReader();


            while (dr.Read())
            {
                Buzz objBuzz = new Buzz();


             objBuzz.Title = dr["TITLE"].ToString(); 
            //TITLE is the Column in BUZZ table
             objBuzz.Desc = dr["DESCRIPTION"].ToString();
            //DESCRIPTION is the Column in BUZZ table


                objBuzzList.Add(objBuzz);
            }


            GridView1.DataSource = objBuzzList;
            GridView1.DataBind();
        }









Wednesday, April 18, 2012

Views in SqlServer

SQL Server excludes an ORDER BY clause from a view to comply with the
ANSI SQL-92 standard. The only time that SQL Server supports an ORDER BY clause in a view is when it is used in conjunction with the TOP keyword. Note that the TOP keyword
is a SQL Server extension to the ANSI SQL-92 standard.
Source: http://dotnetguts.blogspot.in/2007/08/faq-on-view-in-sql-server.html