T-SQL 使用经典 ASP 显示 BLOB 图像

发布于 2025-01-03 18:58:53 字数 1656 浏览 1 评论 0原文

我使用此示例来显示图像,这些图像以 blob 格式存储在启用文件流的数据库中。

http://support.microsoft.com/kb/173308

这工作完美,但我在经典 asp 中非常糟糕,并且在尝试显示与 HTML 元素混合的图像时出现问题。

根据我的测试和尝试,我得出结论,这是因为 Response.ContentType。

在上面的示例中,为了显示图像,他们使用图像的内容类型。完美的。我的数据库里也有这个。但是当我从那里读取它并在 asp 文件中更改它时,asp 文件中的整个 HTML 不会显示。

我应该怎么做才能显示与 HTML 标签混合的图像。这是我糟糕的 asp 代码的一部分,它只会显示数据库中的一张图片,而不显示其他 HTML。

SQL = "SELECT RecordID FROM InfoTable"

Set Recordset = Server.CreateObject("ADODB.Recordset")

Recordset.Open SQL,AdapterDataBaseActiveConnection

If Recordset.EOF Then

    Response.Write("No records returned.")

Else

    Do While NOT Recordset.Eof  

        Set CurrentNumber=Recordset("RecordID") 

        'Response.write CurrentNumber
        'Response.write "<br>" 
        Set rs = AdapterDataBaseActiveConnection.Execute("SELECT ContentType FROM InfoTable WHERE RecordID="&CurrentNumber)
        Set CurrentContentType=rs("ContentType")

        'Response.write CurrentContentType
        Response.Expires = 0
        Response.Buffer = TRUE
        Response.Clear
        Response.ContentType = CurrentContentType

        Set rsa = AdapterDataBaseActiveConnection.Execute("SELECT RecordBLOB FROM ImageTable  WHERE RecordID="&CurrentNumber)
        'Response.write "<div>"
        Response.BinaryWrite rsa("RecordBLOB")
        'Response.write "</div>" 

        Recordset.MoveNext 

    Loop

End If      

我的最终目标是将 blob 数据放入“”标签中。这可能吗?也许我应该使用某种类型的转换?我也想过这个问题,然后就放弃了。我刚刚尝试在“”标签中显示图像,但也没有成功。

请给我一些关于在这种情况下我应该如何处理的建议。

先感谢您。

I am using this example to display images, stored in my File-Stream Enabled database in a blob format.

http://support.microsoft.com/kb/173308

This is working perfect, but I am very bad in classic asp and have problem when try to display this images mix with HTML elements.

From my test and tries, I have concluded that this is because the Response.ContentType.

In the example above, to display the image they are using a content type of the image. Perfect. I have this in my database, too. But when I read it from there and change it in the asp file, the whole HTML in the asp file is not displayed.

What should I do in order to display my images mixed with HTML tags. This is part of my poor asp code, which will display only one picture form the database and no other HTML.

SQL = "SELECT RecordID FROM InfoTable"

Set Recordset = Server.CreateObject("ADODB.Recordset")

Recordset.Open SQL,AdapterDataBaseActiveConnection

If Recordset.EOF Then

    Response.Write("No records returned.")

Else

    Do While NOT Recordset.Eof  

        Set CurrentNumber=Recordset("RecordID") 

        'Response.write CurrentNumber
        'Response.write "<br>" 
        Set rs = AdapterDataBaseActiveConnection.Execute("SELECT ContentType FROM InfoTable WHERE RecordID="&CurrentNumber)
        Set CurrentContentType=rs("ContentType")

        'Response.write CurrentContentType
        Response.Expires = 0
        Response.Buffer = TRUE
        Response.Clear
        Response.ContentType = CurrentContentType

        Set rsa = AdapterDataBaseActiveConnection.Execute("SELECT RecordBLOB FROM ImageTable  WHERE RecordID="&CurrentNumber)
        'Response.write "<div>"
        Response.BinaryWrite rsa("RecordBLOB")
        'Response.write "</div>" 

        Recordset.MoveNext 

    Loop

End If      

My final goal is to put the blob data into "" tags. Is this possible?Maybe I should use some type of conversion? I have thought about this, and given up. I have just try to display the images in "" tags but not succeeded too.

Please, give me some advice about how should I approach in this situation.

Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感情旳空白 2025-01-10 18:58:53

通常它的工作方式如下:

这是页面中的图像

服务器应答 ONE 请求,设置 MIME 标头并流式传输该特定图像的图像数据。您没有输出 HTML,该 html 已经在页面中了。您需要告诉 img 标签从哪里获取其数据。

请参阅:使用 Response.BinaryWrite 显示 JPEG

Typically it works this way:

This is the image in the page <img src="imageServer.asp?ID=1234">

The server answers the ONE request, sets the MIME header and streams the image data for this particular image. You are not outputting HTML, the html is in the page already. You need to tell the img tag where to get its data.

See: Display JPEG using Response.BinaryWrite

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文