如何从数据库中读取图象

skydaxia 2003-08-21 11:19:27
如何从sql server数据库中读取图象(c#的)
...全文
25 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2003-08-21
  • 打赏
  • 举报
回复
HOW TO: Copy a Picture from a Database Directly to a PictureBox Control with Visual C#
http://support.microsoft.com/default.aspx?kbid=317701
skydaxia 2003-08-21
  • 打赏
  • 举报
回复
要加载到picturebox
panyee 2003-08-21
  • 打赏
  • 举报
回复
<%@Page language="C#"%>
<%@import namespace="System.Data"%>
<%@import namespace="System.Data.SqlClient"%>
<script language="C#" runat="server">
public void Page_Load(Object o, EventArgs e)
{
int ImgID = Convert.ToInt32(Request.Params["id"]);
string connStr = ConfigurationSettings.AppSettings["ConnectionString"];
SqlConnection conn = new SqlConnection(connStr);
string sql = "select * from t_imgs where id = @ImgID";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@ImgID", SqlDbType.Int).Value = ImgID;
conn.Open();
SqlDataReader read = cmd.ExecuteReader();
read.Read();
Response.ContentType = (string)read["type"];
Response.OutputStream.Write((byte[])read["imgData"], 0, (int)read["imgSize"]);
Response.End();
conn.Close();
}
</script>
saucer 2003-08-21
  • 打赏
  • 举报
回复
HOW TO: Read and Write BLOB Data by Using ADO.NET with Visual C# .NET
http://support.microsoft.com/default.aspx?kbid=309158

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧