Asp.net源码专业站
首页->博客空间->洪病毒单用户Blog系统源码>>Admin/AddVideo.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:洪病毒单用户Blog系统源码
当前文件:文件类型 HBDBlog/Admin/AddVideo.aspx.cs[2K,2009-6-12 11:43:44]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.Data.SqlClient; 12 13public partial class Admin_AddVideo : System.Web.UI.Page 14{ 15 protected void Page_Load(object sender, EventArgs e) 16 { 17 18 } 19 protected void btn_add_Click(object sender, EventArgs e) 20 { 21 if (Page.IsValid) 22 { 23 Boolean fileOK = false; 24 String path = Server.MapPath("~/Video/"); 25 if (FileUpload1.HasFile) 26 { 27 String fileExtension = 28 System.IO.Path.GetExtension(FileUpload1.FileName).ToLower(); 29 String[] allowedExtensions = 30 { ".avi", ".wmv" ,".wma",".mp3"}; 31 for (int i = 0; i < allowedExtensions.Length; i++) 32 { 33 if (fileExtension == allowedExtensions[i]) 34 { 35 fileOK = true; 36 } 37 } 38 } 39 40 if (fileOK) 41 { 42 try 43 { 44 FileUpload1.PostedFile.SaveAs(path 45 + FileUpload1.FileName); 46 string picpath = "Video/" + FileUpload1.FileName; 47 string name = FileUpload1.FileName; 48 string dec = tbx_dec.Text; 49 DateTime date = DateTime.Now; 50 51 //读取数据库连接字符串 52 string settings = Convert.ToString(ConfigurationManager.ConnectionStrings["SqlServices"]); 53 //创建数据库连接 54 SqlConnection myconn = new SqlConnection(settings); 55 //打开数据库连接 56 myconn.Open(); 57 //查询SQL语句 58 string strsql = "insert into videos(Video_Name,Adddate,Video_Des,Video_Url)"; 59 strsql = strsql + "values ( '" + name + "','"; 60 strsql = strsql + date + "','" + dec + "','"; 61 strsql = strsql + picpath + "')"; 62 //创建数据库命令 63 SqlCommand mycmd = new SqlCommand(strsql, myconn); 64 //测试用语句 65 //Response.Write(strsql); 66 //Response.End(); 67 mycmd.ExecuteNonQuery(); 68 myconn.Close(); 69 Response.Redirect("VideoManage.aspx"); 70 71 } 72 catch (Exception ex) 73 { 74 lbl_msg.Text = "上传出现问题"; 75 } 76 } 77 else 78 { 79 lbl_msg.Text = "上传文件类型错误!."; 80 } 81 } 82 } 83} 84
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:洪病毒单用户Blog系统源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146