Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How insert a blob in SQL Server without bulk and using ASP?

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

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

like image 707
celsowm Avatar asked May 21 '26 16:05

celsowm


1 Answers

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
like image 122
celsowm Avatar answered May 24 '26 07:05

celsowm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!