注册 登录
编程论坛 ASP.NET技术论坛

从数据库中读取图片的问题

lq_2008 发布于 2008-01-03 14:32, 872 次点击
C#从数据库读图片的问题
我以sqlserver2K中northwind数据库中categories表为例对里面的图片读取,但运行不能读出来.

protected void Button3_Click(object sender, EventArgs e)
    {
        SqlConnection connection = new SqlConnection("server=(local);database=northwind;user id=sa;pwd=");
        connection.Open();
        SqlCommand comm = new SqlCommand("select * from categories", connection);
        SqlDataReader reader = comm.ExecuteReader();
        while (reader.Read())
        {
            Response.ContentType ="image/jpeg";
            Response.BinaryWrite((byte[])reader["Picture"]);  
        }
    }
0 回复
1