⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showdbupload.aspx

📁 asp.net技术内幕的书配源码
💻 ASPX
字号:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<script runat=server>

void Page_Load(Object sender , EventArgs e) 
{
	int intItemID;
	SqlConnection conMyData;
	string  strSelect;
	SqlCommand cmdSelect;
	SqlDataReader dtrSearch;

	intItemID = Convert.ToInt32(Request.Params["id"]);
	conMyData = new SqlConnection( @"Server=localhost;Integrated Security=SSPI;Database=myData" );
	strSelect = "SELECT u_documentType, u_document From Uploads " 
		+ "WHERE u_id=@itemID";
	cmdSelect = new SqlCommand( strSelect, conMyData );
	cmdSelect.Parameters.Add( "@itemID", intItemID );
	conMyData.Open();
	dtrSearch = cmdSelect.ExecuteReader();
	if ( dtrSearch.Read())
	{
		// set Content Type
		Response.ClearHeaders();
		switch ((string)dtrSearch["u_documentType"]) {
			case "doc":
				Response.ContentType = "application/msword";
				break;
			case "ppt":
				Response.ContentType = "application/ppt";
				break;
			case "txt":
				Response.ContentType = "text/plain";
				break;
		}
		Response.BinaryWrite( (byte[])dtrSearch["u_document"] );
	}
	dtrSearch.Close();
	conMyData.Close();
}
</Script>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -