System.Web.HttpPostedFile hpf=this.Request.Files[0];
strsql="Insert into [Code] ([subject],CodeTypeID,StatementID,Uploader,[Memo],File2,[FileName]) values ("+Modu.xstr(this.subject.Text)+","+this.codetype.SelectedItem.Value+","+this.statement.SelectedItem.Value+","+Modu.xstr(this.uploader.Text)+","+Modu.xstr(this.memo.Text)+",a3,"+ Modu.xstr(selectFile(hpf.FileName)) +")";
OleDbCommand odcd=new OleDbCommand();
odcd.Connection=this.oleDbConnection1;
odcd.CommandText=strsql;//"aa";
byte[] bt=new byte[hpf.ContentLength];
hpf.InputStream.Read(bt,0,hpf.ContentLength);
System.Data.OleDb.OleDbParameter odpt=new OleDbParameter("a3",OleDbType.Binary);
odpt.Value=bt;
odcd.Parameters.Add(odpt);
this.oleDbConnection1.Open();
odcd.ExecuteNonQuery();
this.oleDbConnection1.Close();
//这是上传到数据库中的一段代码
//Modu.xstr只是为文本加入了一个单引号
//在设计时有一个File控件