BLOB table
3 ID INT 4 0
0 Name Char 50 1
0 blob image 16 1
0 TYPE CHAR 60 1
saveFile.aspx.cs private void Button1_Click (object sender, System.EventArgs e) {Stream imgdatastream = File1.PostedFile.InputStream; int imgdatalen = File1.PostedFile.ContentLength; string imgtype = File1.PostedFile.ContentType; string name = this. getFileNameByURL (this.File1.PostedFile.FileName); byte [] imgdata = new byte [imgdatalen]; int n = imgdatastream.Read (imgdata, 0, imgdatalen); string connstr = "workstation id = OVERMIND; packet size = 4096; user id = sa; password = sa; data source = OVERMIND; persist security info = False; initial catalog = wztj "; SqlConnection connection = new SqlConnection (connstr); SqlCommand command = new SqlCommand (" INSERT INTO blob (name, type, blob) VALUES (@imgtitle, @ type, @ blob) ", connection); SqlParameter paramTitle = new SqlParameter (" @ imgtitle ", SqlDbType.VarChar, 50); paramTitle.Value = name; command.Parameters.Add (paramTitle) Sqlparameter paramdata = new sqlparameter ("@blob", sqldbtype.image); paramdata.value = IMGDATA; command.Parameters.Add (paramData); SqlParameter paramType = new SqlParameter ( "@type", SqlDbType.VarChar, 50); paramType.Value = imgtype; command.Parameters.Add (paramType); wztj.debug.TestSQL.TraceErrorSql ( "INSERT INTO BLOB (Name, Type, Blob) Values (@Imgtitle, @ type, @ blob), command.parameters; connection.open (); int NumrowSaffected = Command.executenonQuery (); connection.close (); } Listfile.aspx // This thing is mainly used to list it, list existing things DataNavigateUrlFormatString = "./ getFile.aspx? ID = {0}" DataTextField = "name" DataTextFormatString = "{0}" ItemStyle-HorizontalAlign = "Center" ItemStyle-Width = "160px"> listFile.aspx.cs string connstr = "workstation id = OVERMIND; packet size = 4096; user id = sa; password = sa; data source = OVERMIND; persist security info = False; initial catalog = wztj"; SqlConnection connection = new SqlConnection (connstr); SqlCommand command = new Sqlcommand ("Select * from blob", connection; connection.open (); sqldataadapter adaptor = new sqldataadapter (Command); DataSet DS = New DataSet (); adaptor.fill (DS, "blob"); connection.close ); This.DataGrid1.datasource = ds.tables ["blob"]. Defaultview; this.dataGrid1.database (); getfile.aspx.cs // This file is more important to put the files in the village database, according to the format, According to the name, send it to the transfer void page_load (object sender, system.eventargs e) {string imgid = this.request.QueryString.get ("ID"); //request.querystring["imgid "]; string connStr =" Workstation id = overmind; packet size = 4096; user ID = sa; password = sa; data s ource = OVERMIND; persist security info = False; initial catalog = wztj "; string sql =" SELECT name, blob, type FROM blob WHERE id = " imgid; SqlConnection connection = new SqlConnection (connstr); SqlCommand command = new SqlCommand ( SQL, Connection; connection.open (); sqldatarader dr = command.executeReader (); if (Dr.Read ()) {response.clear (); response.buffer = true; response.charset = "gb2312"; response .Contentencoding =