Add(sodP);.Parameters.Add(dataP);.Parameters.Add(kompP);_pP.Value =DropDownList1.SelectedValue; _stP.Value=HiddenField1.Value; _predP.Value=DropDownList2.SelectedValue; _kP.Value=DropDownList3.SelectedValue; _fP.Value=CompleteFilePath.Substring (CompleteFilePath.LastIndexOf ( ) + 1) ; .Value=BLOB; .Value=System.DateTime.Now; .Value=Request.ServerVariables [ REMOTE_ADDR ]. ToString ();
//Execute the command and save the BLOB to the database.
{. Connection.Open () ;. ExecuteNonQuery ();
//Response.Write(@laquo;lt;scriptgt;alert(raquo;laquo;Сохранёнraquo;laquo;);lt;/scriptgt;raquo;);.Text = Laquo; Збережений raquo ;;
} (Exception ex)
{
//Response.Write (@ lt; script gt; alert ( Чи не збережений ); lt;/script gt; ) ;. Text= Чи не cохранён raquo ;;
}
{. Connection.Close ();
}
{. Delete (true);
} (Exception ex)
{
}
} (Exception ex)
{. Text= Потрібно вибрати файл raquo ;;
}
}
Панель читача, перегляд даних
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 Student_Prosmotr: System.Web.UI.Page
{SqlConnection www=new SqlConnection ( Data Source =. SQLEXPRESS; AttachDbFilename=| DataDirectory | DB_Rabota.mdf; Integrated Security=True; User Instance=True ); void Page_Load (object sender, EventArgs e)
{(! IsPostBack)
{(Request.UrlReferrer == null)
{. Redirect ( Default.aspx ) ;;
}
}
{. Value=((HiddenField) Page.PreviousPage.FindControl ( HiddenField2 )). Value; .Text=HiddenField1.Value;
} (Exception ex)
{
}
} String SavePath= raquo ;; string FullName; OldFileName; string ss; dr=null; void GridView1_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=GridView1.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 ...