如何在没有批量和使用 ASP 的情况下在 SQL Server 中插入 blob?

2022-01-16 00:00:00 blob asp-classic sql-server

我需要将文件上传"到 SQL Server 数据库中.

I need to upload files 'into' a SQL Server database.

我需要一个不涉及批量插入的解决方案.

I need a solution that doesn't involve bulk inserts.

推荐答案

Set ObjStr = Server.CreateObject("ADODB.Stream")
ObjStr.Type = 1 'AdBinary
ObjStr.Open

ObjStr.LoadFromFile "D:file.pdf"

'Evita sql inject
Set oPreparedStatementADO              = Server.CreateObject("ADODB.Command")
oPreparedStatementADO.ActiveConnection = conexao
cSql = "INSERT INTO edital_editais(blob_field) values (?); "


oPreparedStatementADO.CommandText = cSQL

x = ObjStr.Read

oPreparedStatementADO.Parameters.Item(0) = x

set rs = oPreparedStatementADO.Execute

相关文章