Subject RE: [firebird-support] BLOB TYPE 1 and asp (via ODBC)
Author Alan McDonald
> I need to add a text blob column to one of my tables which is being
> accessed through asp-pages.
>
> I use the Firebird ODBC Driver v1.2.0 software.
>
> Are there any know issues with blobs accessed with asp pages ?
>
> I certainly need to display the data and if at all possible, update
> the data also (let the user write or paste some text, which is than
> stored inside the table).
>
> Any help would be greatly appreciated.

there's no issues other than the normal 128k form submission limitation
which is IIS not FB (Dundas has a free upload component and StateServer if
you want to get fancy. After this you need to do multi-part submission. You
can use a parametised SP or parametised Query in the same way. I'd recommend
not using inline values to avoid inhection of SQL and exceptions raised by
string terminators. But I would highly recommend you look at PHP instead.
You can't run ASP on linux if ever want to move the code. ASP is a dead
technology now in lieu of asp.net etc.


This code should give you some ideas. The blob field is a adParamInput, type
adVarChar, size 65535. After this size you need multipart submissions.


Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = DBConn
DBConn.BeginTrans
rsAdno = DBConn.Execute("SELECT OADNO FROM NEWADNO")
cmd.CommandText = "ADVERTISEMENTS_I"
cmd.CommandType = adCmdStoredProc
cmd.Parameters.Append cmd.CreateParameter( "ID", adInteger, adParamInput)
cmd.Parameters("ID") = CLng(rsAdno("OADNO"))
cmd.Parameters.Append cmd.CreateParameter( "LINKTOMEMBER", adInteger,
adParamInput )
cmd.Parameters("LINKTOMEMBER") = CLng(Request.Cookies("USERID"))
cmd.Parameters.Append cmd.CreateParameter( "JOBTITLE", adVarChar,
adParamInput, 100 )
cmd.Parameters("JOBTITLE") = MID(Request.Form("jobtitle"),1,100)
cmd.Parameters.Append cmd.CreateParameter( "SHORTDESCRIPTION", adVarChar,
adParamInput, 65535 )
cmd.Parameters("SHORTDESCRIPTION") =
SQLQuote(Request.Form("shortdescription"))
cmd.Execute ,, adCmdStoredProc + adExecuteNoRecords
' Commit this transaction
DBConn.CommitTrans

Public Function SQLQuote(str)
'repeat all single quotes
SQLQuote = Replace(str, "'", "''")
End Function

global.asa contains this code:
Application("MainConn_ConnectionString") = "DSN=ODBCDSNName;User
Id=myuserid;PASSWORD=mypassword;"
Application("MainConn_ConnectionTimeout") = 15
Application("MainConn_CommandTimeout") = 30
Application("MainConn_CursorLocation") = 3
Application("MainConn_RuntimeUserName") = "myuserid"
Application("MainConn_RuntimePassword") = "mypassword"

DBConn defined as:
<script LANGUAGE="JScript" RUNAT="Server">
var DBConn = Server.CreateObject('ADODB.Connection');
DBConn.ConnectionTimeout = Application('MainConn_ConnectionTimeout');
DBConn.CommandTimeout = Application('MainConn_CommandTimeout');
DBConn.CursorLocation = Application('MainConn_CursorLocation');
DBConn.Open(Application('MainConn_ConnectionString'),
Application('MainConn_RuntimeUserName'),
Application('MainConn_RuntimePassword'));
</script>