kennethcky
asked on
ASPSmartUpload file.FileToField problem!!!!!!
HI could you tell me what is the problem with my code below?
************************** ********** ****
<%
Set uPBinaryFile = Server.CreateObject("aspSm artUpload. SmartUploa d")
uPBinaryFile.Upload
set dbConn = Server.CreateObject("ADODB .Connectio n")
dbConn.Open = "Driver={mySQL ODBC 3.51 Driver};Server=kenneth;dat abase=ecep ;uid=root; pws=123456 "
set rs = Server.CreateObject("ADODB .Recordset ")
sql = "select image,filename,imagetype from mainpage_layout"
Set rs.ActiveConnection = dbConn
rs.Source = sql
rs.LockType = 3
rs.Open
For each file In uPBinaryFile.Files
If not file.IsMissing Then
rs.AddNew
file.FileToField rs.Fields("image") <--- LINE 19
rs("FileName") = file.filename
rs("ImageType") = file.ContentType
rs.update
intCount = intCount + 1
end if
Next
%>
<%
rs.Close
dbConn.Close
Set rs = Nothing
Set dbConn = Nothing
%>
************************** ********** ******
Error Mesg :
ADODB.Field error '800a0c93'
Operation is not allowed in this context
uploadsave.asp, line 19
LINE 19 IS "file.FileToField rs.Fields("image")"
I'm using MySQL. FYI, Access and Ms SQL 2000 are working and it only happened when i use MySQL
image datatype = "longblob"
If I comment line 19 it work correctly
Please advice ....
**************************
<%
Set uPBinaryFile = Server.CreateObject("aspSm
uPBinaryFile.Upload
set dbConn = Server.CreateObject("ADODB
dbConn.Open = "Driver={mySQL ODBC 3.51 Driver};Server=kenneth;dat
set rs = Server.CreateObject("ADODB
sql = "select image,filename,imagetype from mainpage_layout"
Set rs.ActiveConnection = dbConn
rs.Source = sql
rs.LockType = 3
rs.Open
For each file In uPBinaryFile.Files
If not file.IsMissing Then
rs.AddNew
file.FileToField rs.Fields("image") <--- LINE 19
rs("FileName") = file.filename
rs("ImageType") = file.ContentType
rs.update
intCount = intCount + 1
end if
Next
%>
<%
rs.Close
dbConn.Close
Set rs = Nothing
Set dbConn = Nothing
%>
**************************
Error Mesg :
ADODB.Field error '800a0c93'
Operation is not allowed in this context
uploadsave.asp, line 19
LINE 19 IS "file.FileToField rs.Fields("image")"
I'm using MySQL. FYI, Access and Ms SQL 2000 are working and it only happened when i use MySQL
image datatype = "longblob"
If I comment line 19 it work correctly
Please advice ....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
2) If you are trying to binaryWrite image data to an ASP page that also has plain text content, consider retrieving this data in a separate file and pointing to it via <IMG SRC>. You can also see http://support.microsoft.com/?kbid=276488 for ways to use ADODB.Stream to return binary content from a database, without using the GetChunk method.
When using aspSmartUpload with the same type of setup as initially stated by 'kennethcky', I found I needed to set the cursor location to client in order to upload images and files to MySQL. I set this in the connection object and all seemed to work fine.
objConn.CursorLocation = 3 'adUseClient
objConn.CursorLocation = 3 'adUseClient
<%
sql = "EXEC SP_doSomething @param1=1, @param2='" & var & "'"
set conn = Server.CreateObject("ADODB
conn.open "<connection string>"
set rs = conn.execute(sql)
...
%>