473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Long Raw Type Mismatch error

I'm new to using long raw fields with ASP. I know it would be easier
to leave the files on the file system, but the client wants them in
the database. Based on what I've read so far, I have used the
following code to read files from a hard drive and stuff them in the
database.

<%

'================================================= ===================================
'Function to read a binary file from disk
Function ReadBinaryFile(FileName)
Const adTypeBinary = 1

'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")

'Specify stream type - we want To get binary data.
BinaryStream.Type = adTypeBinary

'Open the stream
BinaryStream.Open

'Load the file data from disk To stream object
BinaryStream.LoadFromFile FileName

'Open the stream And get binary data from the object
ReadBinaryFile = BinaryStream.Read
End Function

'================================================= ===================================
' MAIN

dim objConn
DBObjConn() 'Open database
Set RS = CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM pictures WHERE 1=0"

objConn.beginTrans

RS.Open SQL, objConn, adOpenKeyset, adLockOptimistic, adCmdText

Set FileSystem=CreateObject("Scripting.FileSystemObjec t")
root = Request.ServerVariables("APPL_PHYSICAL_PATH")
rootFilePath = root & "IQInputSource\crt_AGT1500"
filepath = FileSystem.GetAbsolutePathName(rootFilePath)
Set folder=FileSystem.GetFolder(filepath)
Set objFileList = folder.Files

for each objFile in objFileList
filename = objFile.Name
gfxSpex objFile.Path, width, height, depth, filetype
If InStrRev( LCase(filename), ".gif" ) OR InStrRev( LCase(filename),
".jpg" ) THEN
partnumber = Left(filename, InStr(filename,".")-1 )
RS.AddNew
RS("vcpartnumber") = partnumber
RS("width") = width
RS("height") = height
RS("vcfiletype") = filetype
RS("imagedata").appendChunk( ReadBinaryFile(objFile.Path) )
RS.update
End If
next

RS.close

objConn.commitTrans
%>
This seems to work fine, however, when I try and pull the images out
again, it doesn't always work. Some images come out and display just
fine others give me the following error.

error 'ASP 0106 : 80020005'
Type Mismatch, line 18
An unhandled data type was encountered.

Why would I get this only with some rows and not all of them? I
thought maby file size had something to do with it, but after doing
some checking, that doesn't seem to be the case. The code I'm using to
retrieve the data is pretty much straight from Microsoft's site.

<%
dim objConn
DBObjConn() 'Open database

id = Request.QueryString("id")

cmdsql = "SELECT imagedata, vcfiletype from pictures WHERE
vcpartnumber ='"&id&"'"
set rs = Server.CreateObject("adodb.Recordset")
rs.open cmdsql, objConn

Response.ContentType = "image/" & rs("vcfiletype")

Response.Expires = 0
Response.Buffer = TRUE
Response.Clear

temp = rs("imagedata")
Response.BinaryWrite temp
Response.End
%>
Any help is greatly appreciated.

-Sean
Jul 19 '05 #1
0 3448

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Arun Wadhawan | last post by:
Hello MY SQL Server is causing me this problem : Microsoft VBScript runtime error '800a000d' Type mismatch: 'ident' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> I am getting from...
4
by: Mike | last post by:
I am getting a type mismatch error when I do a bulk insert. ---Begin Error Msg--- Server: Msg 4864, Level 16, State 1, Line 1 Bulk insert data conversion error (type mismatch) for row 1, column...
0
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query...
4
by: Robert Hanson | last post by:
Hi All, I am trying to add a record to a datatable that is connected to an Access database. I had no trouble with string and date fields, but for this record, I have two Long Integer field...
1
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. ...
3
by: amitbadgi | last post by:
I am getting teh following error while converting an asp application to asp.net, Exception Details: System.Runtime.InteropServices.COMException: Type mismatch. Source Error: Line...
1
by: Brett | last post by:
I have a form that calls a method within a DLL. By clicking a button on the form, the DLL is instantiated and the SaveOutlookMessage() method invoked. The DLL code copies messages from Outlook to...
6
by: Howard Kaikow | last post by:
I'm doing a VB 6 project in which I am trying to protect against type mismatch errors. Is the process any different in VB .NET? Here's what I'm doing in VB 6. I have an ActiveX DLL. The...
19
by: zz12 | last post by:
Hello, is there a setting in IIS 5.0 that would quickly fix the following error?: Microsoft VBScript runtime (0x800A000D) Type mismatch It's strange because some of our .asp pages were...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.