Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Backup 1

// description of your code here

        Int32 FileID = 102;
        string strConnection = WebConfigurationManager.ConnectionStrings["IntranetaddonConnectionString"].ConnectionString;
        string strSQL = "Select * from wp_DeviationReportFiles where FileID =" + FileID  +  "";
        SqlConnection myConnection = new SqlConnection(strConnection);
        myConnection.Open();

        SqlCommand cmdGetFile = new SqlCommand(strSQL, myConnection);

        SqlDataReader myDataReader;


        myDataReader = cmdGetFile.ExecuteReader();
        if (myDataReader.Read())
        {
            Int32 myyInt = Convert.ToInt32(myDataReader["fileSize"]);
           byte[] result = (byte[])myDataReader["BinaryData"];
           Response.ContentType = "text/plain";
           Response.OutputStream.Write(result, 0, myyInt);
           Response.AddHeader("Content-Disposition", "attachment;filename=" + myDataReader["FileName"].ToString());
           

        }
        else
        {
            Response.Write("File Not Found.");
        }

You need to create an account or log in to post comments to this site.


Click here to browse all 7718 code snippets