Wednesday, December 23, 2009

Sql Server Interview

http://vyaskn.tripod.com/iq.htm


1). Sql server datetime maxlength and minlength ?
1). Min : 1/1/1753 , Max: 12/31/9999

2). Consider the following two tables:
1. customers( customer_id, customer_name)
2. branch ( branch_id, branch_name )
What will be the output if the following query is executed:
Select * branch_name from customers,branch
a. It will return the fields customer_id, customer_name, branch_name
b. It will return the fields customer_id, customer_name, branch_id, branch_name
c. It will return the fields customer_id, customer_name, branch_id, branch_name, branch_name
d. It will return an empty set since the two tables do not have any common field name
e. It will return an error since * is used alone for one table only 
2) b is correct

3) Global variables ?
a). @@rowcount
b). @@version
c). @@error
d). @@colcount
3) d is invalid



 

Sql nth highest salary

Thanks to Pinal dave for his contribution in sql. I have found a very knwn and mostly asked sql question of how to find nth highest salary?
SELECT     TOP (1) sal
FROM         (SELECT DISTINCT TOP (n) sal
                       FROM          emp
                       ORDER BY sal DESC) AS a
ORDER BY sal;



Replace Top (n)  with nth salary number required

blog.sqlauthority.com/.../sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/

Wednesday, December 16, 2009

Regular Expression to match date dd/mm/yyyy

Regular Expression to check date format dd/mm/yyyy



ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[-
/.](19|20)\d\d"

Friday, December 11, 2009

gzip html

http://www.stardeveloper.com/articles/display.html?article=2007110401&page=1
http://www.stardeveloper.com/articles/display.html?article=2007110401&page=1

Thursday, December 10, 2009

Jquery: Slideshow

http://malsup.com/jquery/cycle/

My requirement: something like http://dell.co.in/.  Here, we can see a flash being displayed fews images are faded and new image is listed and also we can see page number just above the images.
Now Jqeury's cycle plugin is what came to my rescue as i had not to write any code and just select the pattern and your is done.

To display navigation above images do following:

// wrapper  
//div for images      



create the above structure for images

Now navigation

$(function() {
    $('#s4').after('

Saturday, November 21, 2009

DataTable : filter columns

so far we must have tested rowfilter property of dataview

eg : dataview dv = ds.tables[0].DefaultView;

What if i need selected Columns from DataView: use ToTable()

Step 1: create a string array to store column names
eg:      string[] cols ={"EmpNo","Ename","Esal"};
Step2:  call ToTable() method
eg:    DataTable dt = dv.ToTable(false,cols); // false - set to true if you want to display distinct records

GridView HeaderText

I had a gridview with autogenerate="true" when i binded the gridview with datatable it displayed the column names from table in the header row.
To change that:

1). Sql : Use as alias in stored procedure
2). DataTable: dt.columns["colname/index"].ColumnName="userdefined Column Name" here
3). GridView:  grdView.HeaderRow.Cells[0].Text="Assign the Name "

Custom validator - file upload size limit check

Place a customValidator with fileupload control
HTML
set its id, controltovalidate="fileuploadControlname", onservervalidate="cs1_serverValidate", errormessage="cannot upload file greater than 1 kb"


Code Behind

protected void cs1_serverValidate(object source,ServerValidateEventArgs args )
{
    if(fielupload1.filesBytes.Length > 1024)
      {
             args.IsValid = false;
       }
else
{
      args.IsValid = true;

]


}

File Upload - upload file more than 4 mb

Web.config

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="32768" />
    system.web>
configuration>

Thursday, November 19, 2009

Tuesday, November 17, 2009

Stack and Heap

Click below :

Stack and Heap

Magic Tables

Usually Inserted and Deleted Tables are called Magic Tables.Magic Tables does not contain the information about
the Columns of the DataType text,ntext or image.These are maintained by SQL Server for internal processing whenver an update,insert,Delete occur on table.However we can refer these tables in Triggers.
Whenever an updated table statement is fired SQL Server Maintains the original row before updation in a deleted table and New(Updated) row in inserted table.

as posted on http://social.msdn.microsoft.com/forums/en-US/transactsql/thread/b1b1cde8-329c-4c86-9bac-5c903e4c04ab

Saturday, November 14, 2009

nested gridview

Here is an example of nested gridview. I have a gridview and inside it another gridview. The innergrid has a dropdownlist control... Now when user changes dropdown selected item i want to get the data of outer gridview.

Here is the code:
<div>
<asp:GridView ID="GridView1" DataKeyNames="id" runat="server" AutoGenerateColumns="false" OnRowDataBound="GridView1_RowDataBound" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" >
<Columns>
<asp:TemplateField HeaderText="Empid">
<ItemTemplate>
<%# Eval("id") %>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<%# Eval("EmpName")%>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="DropDown">
<ItemTemplate>

<asp:GridView ID="innerGrid" AutoGenerateColumns="false" runat="server" OnRowDataBound="innergrid_rowDataBound">
<Columns>
<asp:TemplateField HeaderText="inner grid">
<ItemTemplate>
<asp:DropDownList ID="dd1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="dd1_indexchanged" >
<asp:ListItem Value="1" Text="text1"></asp:ListItem>
<asp:ListItem Value="2" Text="text2"></asp:ListItem>
<asp:ListItem Value="3" Text="text3"></asp:ListItem>
<asp:ListItem Value="4" Text="text4"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


</ItemTemplate>
</asp:TemplateField>

</Columns>
</asp:GridView>

</div>




Code Behind:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default6 : System.Web.UI.Page
{
    DataSet ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            createdataset();
            bindOuterGrid();
        }
    }

    protected void bindOuterGrid()
    {
        GridView1.DataSource = ds;
        GridView1.DataBind();

    }

 

    protected void createdataset()
    {
        #region "Create table"

        DataTable dt = new DataTable();
        DataColumn dc;

        //EmpId
        dc = new DataColumn();
        dc.DataType = Type.GetType("System.String");
        dc.ColumnName = "id";
        dt.Columns.Add(dc);

        //EmpName
        dc = new DataColumn();
        dc.DataType = Type.GetType("System.String");
        dc.ColumnName = "EmpName";
        dt.Columns.Add(dc);
       
        #endregion

        #region "Insert Data"

        DataRow dr;

        dr = dt.NewRow();
        dr[0] = "1";
        dr[1] = "John";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[0] = "2";
        dr[1] = "Jorddon";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[0] = "3";
        dr[1] = "Mathew";
        dt.Rows.Add(dr);


        dr = dt.NewRow();
        dr[0] = "4";
        dr[1] = "Crook";
        dt.Rows.Add(dr);


        dr = dt.NewRow();
        dr[0] = "5";
        dr[1] = "Andrew";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[0] = "6";
        dr[1] = "Luthar";
        dt.Rows.Add(dr);


        dr = dt.NewRow();
        dr[0] = "7";
        dr[1] = "Shane";
        dt.Rows.Add(dr);


        dr = dt.NewRow();
        dr[0] = "8";
        dr[1] = "Vince";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[0] = "9";
        dr[1] = "Smith";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr[0] = "10";
        dr[1] = "Woodsmith";
        dt.Rows.Add(dr);

        ds.Tables.Add(dt);

        #endregion

    }

        protected void dd1_indexchanged(object sender, EventArgs e) 
    {
       
        GridViewRow selectedChildRow = (GridViewRow)(((DropDownList)sender).Parent.Parent) ; 
        //alternatively we can also use 
        //GridViewRow selectedChildRow = ((DropDownList)sender).NamingContainer as GridViewRow; 
        GridViewRow selectedParentRow = (GridViewRow)(selectedChildRow.Parent.Parent.Parent.Parent) ;
        string s = ((DataBoundLiteralControl)(selectedParentRow.Cells[0].Controls[0])).Text;
        Response.Write(s);
        //alternatively we can also use 
        //GridViewRow selectedParentRow = selectedChildRow.NamingContainer.NamingContainer as GridViewRow; 

      
    } 


  

    protected void innergrid_rowDataBound(object sender, GridViewRowEventArgs e)
    {
       
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if(e.Row.RowType == DataControlRowType.DataRow)
        {
            int[] arr = new int[1]{1};
            GridView grd = (GridView)e.Row.FindControl("innerGrid");
            grd.DataSource = arr;
            grd.DataBind();
        }
    }




    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}

Tuesday, November 10, 2009

HTTP overview

HTTP
ref: (http://www.tutorialspoint.com/http/index.htm)
      (http://ftp.ics.uci.edu/pub/ietf/http/rfc1945.html#Introduction)

    1. Overview
    2. Http Message Structure
    3. Http Methods
    4. Http Header Fields
    5. Http Status Code
   
    OverView:
    1. It is a TCP/IP based communication protocol used to deliver files,and other data known as resources over the web.
    2. It is a request/response model (also client/server).
    3. The Browser an HTTP client sends a request to server and expect a corresponding response.
   
    Features:
    1. Http is connectionless : after a request is made, connection is disconnected and to response server again creates a connection with the clien
    2. Http is media independant: can communicate any type of data provided both know how to handle it.
    3. Http is stateless: client/server dont have memory of its own. No storage of requests made.
   
    Request/Response Explained
    1.Request/Response
    2.Header Line
    3. Body
      
Format of Request :     GET    /PATH/TO/FILE/INDEX.HTML  HTTP/1.0

a).GET:  (Method Name)
b)./PATH/TO/FILE/INDEX.HTML: (Path of file)
c).HTTP/1.0: (http version)
   
   
Format of Response:    HTTP/1.0           200                 OK

a). HTTP VERSION   
b). RESPONSE CODE
c). ENGLISH REASON OR EXPLANATION OF CODE
                       
                       
Format Header :
                     Name/value pair
                    eg User-Agent: Mozilla/3.0Gold
                       Last Modified: date       
                      
Body:
           In a REQUEST, this is where user-entered data or uploaded files are sent to the server.
          In a RESPONSE body consists of data sent back to the browser. It also has following headers:
                A). Content-type:header gives the MIME-type of the data in the body, such as text/html or image/gif
                B). Content-Length: header gives the number of bytes in the body

Monday, November 9, 2009

Interviews

  • What are Joins?
  • link:http://www.w3schools.com/sql/sql_join.asp
  • What are different Data Controls used in asp.net?
  • link:
  • Difference between them?
  • link:
  • State Managment?
  • link:
  • Session and viewstate difference?
  • link:
  • Name client side state management and server side state management?
  • link:
  • String and stringbuilder?
  • link:
  • Normalization?
  • link:
  • nvarchar and varchar?
  • varchar : variable length character string , nvarchar: unicode variable length character string. nvarchar is used to store english and non-english symbols.like english and japaneese . varchar can accept maxlength of 4000 chars.nvarchar require 2bits to store one character whereas varchar require 1 bit per character.

Thursday, November 5, 2009

XML overview

http://www.adobe.com/devnet/dreamweaver/articles/xml_overview_04.html

Ebooks Link

ebook
mcts -> filestube.com

CSS:display property

http://www.quirksmode.org/css/display.html#inline

Wednesday, November 4, 2009

Asp.Net:Progressbar

http://www.aspnettutorials.com/tutorials/themes/progress-bar-csharp.aspx
http://www.javascriptkit.com/script/script2/progressbar.shtml
http://msdn.microsoft.com/hi-in/magazine/cc163553%28en-us%29.aspx

must visit links