Saturday 30 August 2014

How to download any document file from server?

To download any file from server use the following code:

           
                string file_path="~/files/file.xps";    //relative path of your file on server
                string ext = file_path.Substring(file_path.LastIndexOf('.')+1).ToLower (); //get the extension of file
                string filename="myfile."+ext;            //your file will be downloaded with this name
                System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                response.ClearContent();
                response.Clear();
                if (ext == "pdf")
                    response.ContentType = "application/pdf";
                else
                    if (ext == "txt")
                        response.ContentType = "text/plain";
                    else
                        if (ext == "docx")
                            response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                        else
                            if (ext == "doc")
                                response.ContentType = "application/msword";
                            else
                                if (ext == "xlsx")
                                    response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                                else
                                    if (ext == "xls")
                                        response.ContentType = "application/vnd.ms-excel";
                                    else
                                        if (ext == "xps")
                                            response.ContentType = "application/vnd.ms-xpsdocument";

           
                response.AddHeader("Content-Disposition", "attachment; filename=" +filename+ ";");                                   response.TransmitFile(Server.MapPath(file_path ));
                response.Flush();
                response.End();  

             

How to download a xps file from server?

To download a xlsx file from server use the following code:

           
                string file_path="~/files/file1.xps";    //relative path of your file on server
                string filename="myfile.xps";            //your file will be downloaded with this name
                System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                response.ClearContent();
                response.Clear();
                response.ContentType = "application/vnd.ms-xpsdocument";
                response.AddHeader("Content-Disposition", "attachment; filename=" +filename+ ";");                                   response.TransmitFile(Server.MapPath(file_path ));
                response.Flush();
                response.End();  

             

How to download a xlsx file from server?

To download a xlsx file from server use the following code:

           
                string file_path="~/files/file1.xlsx";    //relative path of your file on server
                string filename="myfile.xlsx";            //your file will be downloaded with this name
                System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                response.ClearContent();
                response.Clear();
                response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                response.AddHeader("Content-Disposition", "attachment; filename=" +filename+ ";");                                   response.TransmitFile(Server.MapPath(file_path ));
                response.Flush();
                response.End();  

             

How to download a xls file from server?

To download a xls file from server use the following code:

           
                string file_path="~/files/file1.xls";    //relative path of your file on server
                string filename="myfile.xls";            //your file will be downloaded with this name
                System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                response.ClearContent();
                response.Clear();
                response.ContentType = "application/vnd.ms-excel";
                response.AddHeader("Content-Disposition", "attachment; filename=" +filename+ ";");                                   response.TransmitFile(Server.MapPath(file_path ));
                response.Flush();
                response.End();  

             

How to download a docx file from server?

To download a docx file from server use the following code:

           
                string file_path="~/files/file1.docx";    //relative path of your file on server
                string filename="myfile.docx";            //your file will be downloaded with this name
                System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                response.ClearContent();
                response.Clear();
    response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                response.AddHeader("Content-Disposition", "attachment; filename=" +filename+ ";");                                   response.TransmitFile(Server.MapPath(file_path ));
                response.Flush();
                response.End();  

             

How to download a doc file from server?

To download a doc file from server use the following code:

           
                string file_path="~/files/file1.doc";    //relative path of your file on server
                string filename="myfile.doc";            //your file will be downloaded with this name
                System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                response.ClearContent();
                response.Clear();
                response.ContentType = "application/msword";
                response.AddHeader("Content-Disposition", "attachment; filename=" +filename+ ";");                                   response.TransmitFile(Server.MapPath(file_path ));
                response.Flush();
                response.End();  

             

How to download a text file from server?

To download a text file from server use the following code:

           
                string file_path="~/files/file1.txt";    //relative path of your file on server
                string filename="myfile.txt";            //your file will be downloaded with this name
                System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                response.ClearContent();
                response.Clear();
                response.ContentType = "text/plain";
                response.AddHeader("Content-Disposition", "attachment; filename=" +filename+ ";");                                   response.TransmitFile(Server.MapPath(file_path ));
                response.Flush();
                response.End();  

             

Monday 4 August 2014

What is functional dependency?

A functional dependencies is denoted by X--->Y  between two sets of attributes X and Y that are subsets of R. This means that the value of X component of a tuple uniquely determines the value of component Y

What is 1 NF(Normal Form)?

The domain of attribute must include only atomic(simple, indivisible) values.

What is normalization?

It is a process of analysing the given relation schemas based on their Functional Dependencies(FDs) and primary key to achieve the properties:
  • Minimizing redundancy.
  • Minimizing insertion, deletion and update anomalies.

What is SDL(Storage Definition Language)?

This language is to specify the internal schema. This language may specify the mapping between two schemas

What is VDL(View Definition Language)?

It specifies user views and their mappings to the conceptual schema.

Integrity rules

In SQL we have two integrity rules:
  • Entity Integrity- states that PRIMARY KEY cannot have NULL values.
  • Referential Inntegrity- states that foreign key can be either a NULL value or should be PRIMARY KEY value of other relation

Describe subquery

A subquery is a query that is composed of two queries. The first query (inner query) is within the WHERE clause of the outer query. In some cases the inner query provides results for the outer query to process. In other cases, the outer query results provide results for the inner query