(1, CurrentIndex, Blob, 0, BufferSize);
}
//When the BytesReturned no longer fills
//the buffer, write the remaining bytes..Write (Blob, 0, (int) (BytesReturned)) ;. Flush () ;. Close () ;. Close ();
}. Close () ;. Connection.Close (); (b)
{Fname=Server.MapPath (FullName) ;. ClearContent () ;. ClearHeaders () ;. ContentType= binary/octet-stream raquo ;;. AddHeader ( Content-Disposition raquo ;, attachment; filename= + ss) ;. WriteFile (Fname) ;. Flush () ;. Close ();
}
} (Exception ex)
{. Write (@ lt; script gt; alert ( Неможливо виполнтіть запит ); lt;/script gt; );
}
}
}
Панель адміністратора, перегляд даних
using System;System.Collections;System.Configuration;System.Data;System.Linq;System.Web;System.Web.Security;System.Web.UI;System.Web.UI.HtmlControls;System.Web.UI.WebControls;System.Web.UI.WebControls.WebParts;System.Xml.Linq;System.Data.SqlClient;System.IO;partial class Prepodavatel: System.Web.UI.Page
{void Page_Load (object sender, EventArgs e)
{(! IsPostBack)
{(Request.UrlReferrer == null)
{. Redirect ( Default.aspx ) ;;
}
}
{. Value=((HiddenField) Page.PreviousPage.FindControl ( HiddenField_Prepod_Fio )). Value; .Value=((HiddenField) Page.PreviousPage.FindControl ( HiddenField_kod_prepod )).Value; .Text=HiddenField1.Value;
}
{
}
} void GridView3_SelectedIndexChanged (object sender, EventArgs e)
{. Text=GridView3.SelectedRow.Cells [1] .Text; .Text= не визначена raquo ;;
} SqlConnection www=new SqlConnection ( Data Source =. SQLEXPRESS; AttachDbFilename=| DataDirectory | DB_Rabota.mdf; Integrated Security=True; User Instance=True ); void GridView4_SelectedIndexChanged (object sender, EventArgs e)
{. Text=GridView4.SelectedRow.Cells [1] .Text;
} String SavePath= raquo ;; string FullName; OldFileName; string ss; dr=null; void GridView5_SelectedIndexChanged (object sender, EventArgs e)
{b;
{
//Видалити TEMP з вмістом=new DirectoryInfo (MapPath ( ~ Image/TEMP/));
{. Delete (true);
} (Exception ex)
{
}
//Створити папку TEMP=new DirectoryInfo (MapPath ( ~ Image/TEMP/)) ;. Create ();
//Встановити маршрут TEMP для запису ліченого файлу=MapPath ( ~ Image/TEMP/);
//Створити команду для вибору записуваного файлу з БДGetBlobCommand=new SqlCommand ( SELECT [Ім'я_файлу], [Вміст], [Код_Сведеній] + FROM Відомості + WHERE [ Код_Сведеній] =kod raquo ;, www);
//Встановити параметр.Parameters.Add ( @ kod raquo ;, SqlDbType.BigInt) .Value=GridView5.SelectedRow.Cells [1] .Text;
//Current index to write the bytes toCurrentIndex=0;
//number of bytes to store in the BLOB.BufferSize=100;
//Actual number of bytes returned when calling GetBytes.BytesReturned;
//The Byte array used to hold the buffer. [] Blob=new byte [BufferSize];
//Відкрити соедіненіе.Connection.Open (); reader=GetBlobCommand.ExecuteReader (CommandBehavior.SequentialAccess); (reader.HasRows) b=true; else b=false; (reader.Read ())
{
//Create or open the selected file.=reader [ Ім'я_файлу ]. ToString ();
//OldFileName=SavePath + + Ss;=SavePath + ss;= ~ Image/TEMP/ + Ss; .IO.FileStream FileStream=new System.IO.FileStream (OldFileName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
//Set the writer to write the BLOB to the file..IO.BinaryWriter writer=new System.IO.BinaryWriter (FileStream);
//Reset the index to the beginning of the file.=0;
//Set the BytesReturned to the actual number
//of bytes returned by the GetBytes call.=reader.GetBytes (1, CurrentIndex, Blob, 0, BufferSize);
//If the BytesReturned fills the buffer
//keep appending to the file. (BytesReturned == BufferSize)
{. Write (Blob) ;. Flush (); +=BufferSize;=reader.GetBytes (1, CurrentIndex, Blob, 0, BufferSize);...