Hello,
I'm trying to convert a pdf to binary dato and saving it to my SQL database. When i just output the pdf (from binary) to the user, it works perfectly.
The field in my database for the binary data is image.
Here is what i'm doing atm:
Set oFileStream = Server.CreateObject("ADODB.Stream")
oFileStream.Open
oFileStream.Type = 1 'Binary
oFileStream.LoadFromFile strPDF
And if i do Response.BinaryWrite(oFileStream.Read) the PDF pops to user.
Then i want to store it to SQL:
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "xxx"
strSQL = "INSERT INTO vAnalysesHistory (datetime,chosendatetime,companyid,code,content) VALUES (?,?,?,?,?)"
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = Conn
cmd.CommandType = adCmdText
cmd.CommandText = strSQL
cmd.Parameters.Append cmd.CreateParameter("@datetime", adDate, adParamInput, 255, now)
cmd.Parameters.Append cmd.CreateParameter("@chosendatetime", adDate, adParamInput, 255, Request.Form("date"))
cmd.Parameters.Append cmd.CreateParameter("@companyid", adVarChar, adParamInput, 255, Request.Form("companyid"))
cmd.Parameters.Append cmd.CreateParameter("@code", adVarChar, adParamInput, 255, Request.Form("code"))
cmd.Parameters.Append cmd.CreateParameter("@content", adLongVarBinary, adParamInput, 8000, oFileStream.Read)
cmd.Execute()
Conn.close
Set Conn = Nothing
And i just get this error: Application uses a value of the wrong type for the current operation.
I've tried a bunch of other things also with some other errors.