Monday 25 November 2013

Data Source Controls and Data Controls

Data Source Controls


  • AccessDataSource control   The AccessDataSource control is a data source control that works with Microsoft Access databases.
  • SiteMapDataSource control   The SiteMapDataSource Web server control retrieves navigation data from a site-map provider, and then passes the data to controls that can display that data, such as the TreeView and Menu controls.
  • SqlDataSource control   The SqlDataSource control enables you to use a Data control to access data located in a relational data base, including Microsoft SQL Server and Oracle databases, as well as OLE DB and ODBC data sources.
  • XmlDataSource control   The XmlDataSource control makes XML data available to data-bound controls. You can use it to display both hierarchical and tabular data, although the XmlDataSource control is typically used to display hierarchical XML data in read-only scenarios.

    Data Control


  • DataList control   The DataList control is useful for displaying data in any repeating structure, such as a table. The DataList control can display rows in different layouts, such as ordering them in columns or rows.
  • DetailsView control   The DetailsView control gives you the ability to display, edit, insert, or delete a single record at a time from its associated data source. The DetailsView control displays only a single data record at a time, even if its data source exposes multiple records.
  • FormView control   The FormView control gives you the ability to work with a single record from a data source, similar to the DetailsView control. The difference between the FormView and the DetailsView controls is that the DetailsView control uses a tabular layout where each field of the record is displayed as a row of its own. In contrast, the FormView control does not specify a pre-defined layout for displaying the record. Instead, you create a template containing controls to display individual fields from the record.
  • GridView control   The GridView control displays the values of a data source in a table where each column represents a field and each row represents a record. The GridView control allows you to select, sort, and edit these items. For information about programming the GridView control, see GridView Class in the MSDN library.
  • Repeater control   The Repeater control is a data-bound container control that produces a list of individual items. You define the layout of individual items on a web page using templates. When the page runs, the control repeats the layout for each item in the data source.

Sunday 24 November 2013

The ALTER TABLE Statement and rename column name in sql server

The ALTER TABLE Statement

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.

To add a column in a table, use the following syntax:
 =======================
ALTER TABLE table_name
ADD column_name datatype
============================
To delete a column in a table, use the following syntax 
===============================
ALTER TABLE table_name
DROP COLUMN column_name
=========================
 
To change the data type of a column in a table, use the following syntax:
=======================

ALTER TABLE table_name
ALTER COLUMN column_name datatype
 =========================
 
To rename column name there is no way with alter command 
we use sp_rename proc for this.
 =========================================
The script for renaming any column :

sp_RENAME 'TableName.[OldColumnName]' , '[NewColumnName]', 'COLUMN'
-----------------------------------------------
The script for renaming any object (table, sp etc) :

sp_RENAME '[OldTableName]' , '[NewTableName]'
 
======================================
 
 
 

Example of Recursion

Example of recursion:
============================


 protected void Page_Load(object sender, EventArgs e)
    {

        Quiz(5);

    }
    protected void Quiz(int i)
    {
        if (i > 1)
        {
            Quiz(i / 2);
            Quiz(i / 2);
        }
        Response.Write("*");
        }

=====================
outPut :     *******

Tuesday 19 November 2013

create paging by procdedure in sqlserver

 How To create Paging  Data by Procedure?
 =======================================
 EX.
 ------------------------------------------------------------------

USE [demo]
GO
/****** Object:  StoredProcedure [dbo].[empdatapaging]    Script Date: 11/20/2013 11:54:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[empdatapaging]
@page int=1
as
begin

select * from (select row_number() over(order by first_name asc) as TableID,employee_id,last_name,first_name,salary from employee)as abcd
where TableID between ((@page-1)*3)+1 and @page*3

end

How to Create Table and Copying Structure of Existing Table

Create Table and Copying Structure of Existing Table
=====================================
Ex:-select * into empnew from employee where 1=0

Create Table and Copying Structure of Existing Table with data of existing table
=====================================
Ex:-select * into empnew from employee

रूस-यूक्रेन संकट लाइव: भारतीयों को 'उपलब्ध किसी भी साधन' के माध्यम से कीव को तत्काल छोड़ने के लिए कहा

  रूस यूक्रेन संकट लाइव: कीव में भारतीय दूतावास ने मंगलवार को जारी एक एडवाइजरी में भारतीयों को  'किसी भी उपलब्ध साधन' के माध्यम से क...