using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.web.ui.webcontrols; using system.web.ui.htmlControls; using system.io; using system.configuration;
Summary description of Namespace BJOFFICE {///
public void CreatTable () {SqlConnection myConnection = new SqlConnection (ConfigurationSettings.AppSettings [ "ConnectionString"]); SqlDataAdapter myCommand = new SqlDataAdapter ( "select FileName, FileType, FileLen, FileData, [ID] from Accessories where [ID] <- 1 ", myconnection; dataset mydataset = new dataset (); mycommand.fill (MyDataSet," Accessoriestable "); Upfiles2 = mycommand; Upfiles1 = myDataSet.Tables [Accessoriestable"];}
Private void Page_load (Object Sender, System.EventArgs E) {// Place user code here to initialize page}
#Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is necessary for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} ///
private void Button1_Click (object sender, System.EventArgs e) {if (upfiles1 == null) {CreatTable ();} if (myFile.PostedFile.FileName = ""!) {string filename1 = Path.GetFileName (myFile.PostedFile. FileName); //if (Upfiles1.Rows.Find (FileName )==Null DataRow [] Myrow = Upfiles1.Select ("filename = '" filename1.tostring () "'"; if (Myrow.Length == 0) {int filelen = myFile.PostedFile.ContentLength; string filetype = myFile.PostedFile.ContentType; Stream fstream = myFile.PostedFile.InputStream; byte [] filedata = new byte [filelen]; fstream.Read (filedata, 0 , Filelen;
DATAROW DR = Upfiles1.NewRow (); DR [0] = filename1; DR [1] = fileten; DR [2] = filelen; dr [3] = fileData; Upfiles1.Rows.Add (DR); files.datasource = Upfiles1; files.databind ();